Skip to content

Adapt graphhopper script for dropwizard branch - #1319

Merged
karussell merged 11 commits into
dropwizardify2from
dropwizard_script
Mar 26, 2018
Merged

karussell merged 11 commits into
dropwizardify2from
dropwizard_script

Conversation

@karussell

@karussell karussell commented Mar 23, 2018 •

Copy link
Copy Markdown
Member

And replaces #1244

  • support for gtfs
  • some more short parameters (test measurement and torture) doesn't work at all. we should fix in different PR
  • convert all unknown parameters into -Dgraphhopper.<unknown> instead of printing the error? Problem is that this could hide compatibility issues between this and the old arguments. We can do this in one of the next releases as for now other parameters are possible via the old export GH_WEB_OPTS=xy approach
  • make old approach working: export JETTY_PORT=8990;./graphhopper.sh web ~/Downloads/berlin-latest.osm.pbf even when port is removed from config use -port command line option instead
  • even if not configured the admin stuff is started! no problem when we bind to localhost
  • test IPFilter can be remove since we bind to localhost

Let us also document the old vs. the new way of configuring something:

old new
export JETTY_PORT=8989 --port 8989
export GH_FOREGROUND=false -d

…ameter is required if empty); avoid starting admin connector
Comment thread graphhopper.sh
fi

# default init, https://stackoverflow.com/a/28085062/194609
: "${CONFIG:=config.yml}"

@justinmk2 justinmk2 Mar 23, 2018 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

: is a easy-to-miss synonym for true. This form is clearer (or at least far more common):

CONFIG=${CONFIG:-config.yml}

and doesn't require studying a stackoverflow post.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice update.
I was reading again the flags, and I have perhaps others suggestions:

  • -r for --datareader.file
  • -d for --run-backgound or --detach (which is really common for different software)
  • -f for --force-download (it can still be -fd!)

@karussell karussell Mar 23, 2018 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@legraina Thanks! For -r I'm not sure. I think -f for "file" is not uncommon. Maybe -i or -in for input as we have -o for output ...

and doesn't require studying a stackoverflow post.

@justinmk2 the other method requires typing the variable twice ;) (maybe useful later for long variables) and to be honest the :- is not 100% clear too and the := smells more intuitive

@karussell
karussell requested a review from michaz March 24, 2018 00:28
@karussell

karussell commented Mar 24, 2018 •

Copy link
Copy Markdown
Member Author

Have updated also with look to comments from @legraina. For me this seems to be ok for now and we should try this a bit and improve step by step, e.g. some actions do not work at all but this would require some more class similar to the import action.

Using GTFS is also possible now with this script

E.g. the short form looks like:

export JAVA_OPTS="-Xmx10g -Xms10g"; ./graphhopper.sh -a web -i berlin-latest.osm.pbf -ig ~/Downloads/gtfs.zip -p pt

long form:

export JAVA_OPTS="-Xmx10g -Xms10g"; ./graphhopper.sh --action web --input berlin-latest.osm.pbf --gtfs gtfs.zip --profiles pt

(the test failure is something else I tried to fix in another commit but obviously it wasn't that successful)

update:

the short form looks like:

export JAVA_OPTS="-Xmx10g -Xms10g"; ./graphhopper.sh -a web -i berlin-latest.osm.pbf --gtfs.file ~/Downloads/gtfs.zip -p pt

long form:

export JAVA_OPTS="-Xmx10g -Xms10g"; ./graphhopper.sh --action web --input berlin-latest.osm.pbf --gtfs.file gtfs.zip --profiles pt

Comment thread graphhopper.sh Outdated
echo "-c | --config: specify the application configuration"
echo "-host: specify to which host the service should be bound"
echo "-port: start web server at specific port"
echo "-jar: specify the jar file (useful if you want to reuse this script for custom builds)"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or should we better do something like -h | --host and -p | --port (clashes with --profiles) and -j | --jar?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it will be nice. I think you should use -p for port, and perhaps just --profile without a short version.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. Maybe -v for --vehicle-profiles but yes, --profiles is also ok

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-h for --host would clash with -h for help :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And -v should be used for version. So I currently prefer to use --host and --port and --jar

@michaz

michaz commented Mar 24, 2018

Copy link
Copy Markdown
Member

Looks good to me.. Nice to see that the script could get shorter.

…'-' prefix; use -- for parameters longer than 2 characters; added possibility to print version
@karussell
karussell merged commit e4970f2 into dropwizardify2 Mar 26, 2018
@karussell
karussell deleted the dropwizard_script branch March 26, 2018 22:00
karussell pushed a commit that referenced this pull request Apr 7, 2018
* Initial attempt at dropwizardifying

* Remove CmdArgsModule

* For example: ChangeGraph

* For example: Nearest

* No more Guice, no more Servlets

* Bundle configuration; mergin of system properties

* config-example.yml

* Add OSM file name to example

* Add port number to example config

* Dropwizard import command

* ChangeGraphResource is disabled by default

* rename hk2 factories to *Factory

* redirect to webapp from root

* dropwizard 1.1.2

* Add banner.txt

* Restore tests for http error status codes, and fix it.

* Insert separate fields for planned/predicted departure/arrival time

Signed-off-by: Michael Zilske <[email protected]>

* Set the expected times fields only when there is an update.

Signed-off-by: Michael Zilske <[email protected]>

* Insert separate fields for planned/predicted departure/arrival time

* Bump Dropwizard version; declare J2EE dependencies (for Java 9)

Signed-off-by: Michael Zilske <[email protected]>

* Use the same Jackson version in the client.

Signed-off-by: Michael Zilske <[email protected]>

* Remove client-duplicate, as in master

Signed-off-by: Michael Zilske <[email protected]>

* Adapt to refactoring

Signed-off-by: Michael Zilske <[email protected]>

* Use shade plug-in as per Dropwizard doc

Signed-off-by: Michael Zilske <[email protected]>

* Disable Dropwizard admin port in default config

Signed-off-by: Michael Zilske <[email protected]>

* Remove empty files

Signed-off-by: Michael Zilske <[email protected]>

* Fix banner

Signed-off-by: Michael Zilske <[email protected]>

* Move webapp from /webapp to /maps

Signed-off-by: Michael Zilske <[email protected]>

* Disable request log

Signed-off-by: Michael Zilske <[email protected]>

* Add a (not very strong) Dropwizard health check to each of the two API variants.

I think this is okay for now -- they are thinking more of testing the health of external services such as databases.

Signed-off-by: Michael Zilske <[email protected]>

* Adapt graphhopper script for dropwizard branch (#1319)

* adapt graphhopper.sh script for dropwizard

* now variable JETTY_PORT works (empty would result in random so no parameter is required if empty); avoid starting admin connector

* minor fix

* improve security and bind to private localhost instead of public 0.0.0.0, then we can start admin panel and remove IPFilter

* improve script and include some shortcut to specifiy vehicle profiles and the gtfs input file

* remove logging echo statement

* 'detaching' does not need a value

* minor improvements

* forward parameters as there won't be compatibility issues due to the '-' prefix; use -- for parameters longer than 2 characters; added possibility to print version

* minor cleanup

* sort alphabetically

* added author when adapting graphhopper.sh script for dropwizard #1319

* avoid unnecessary dependency like commons logging

* merged master

* use WebApplicationException

* no tools jar possible, use web jar via ImportCommand

* updated docs

* revert change explicitely #1313
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants