Created
July 10, 2017 19:49
-
-
Save rgwozdz/63e027e7c680387274cd9e900573d42b to your computer and use it in GitHub Desktop.
Setting up Ubuntu java service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # /usr/local/bin/service-name-restart.sh, owner: root, group: root, mode: 0755 | |
| #!/bin/bash | |
| # /usr/local/bin/service-name-restart.sh | |
| # | |
| if [ -f "<java program working dir>/RUNNING_PID" ]; then kill -9 `cat <java program working dir>/RUNNING_PID`; fi | |
| if [ -f "<java program working dir>/RUNNING_PID" ]; then rm <java program working dir>/RUNNING_PID; fi | |
| cd <java program working dir>/bin | |
| env JAVA_OPTS="-Xms4096m -Xmx4096m" ./geotrellis-api -Dconfig.file=<java program working dir>/conf/application.conf -Dhttp.port=7777 -Dplay.crypto.secret=abcdefghijk > <the-log-path> 2>&1 | |
| ######################################################################################################### | |
| # /usr/local/bin/service-name-stop.sh, owner: root, group: root, mode: 0755 | |
| #!/bin/bash | |
| #/usr/local/bin/service-name-stop.sh | |
| # | |
| if [ -f "<java program working dir>/RUNNING_PID" ]; then kill -9 `cat <java program working dir>/RUNNING_PID`; fi | |
| if [ -f "<java program working dir>/RUNNING_PID" ]; then rm <java program working dir>/RUNNING_PID; fi | |
| ######################################################################################################### | |
| # /etc/systemd/system/service-name.service, owner: root, group: root, mode: 0744 | |
| service-name.service | |
| [Unit] | |
| Description=start service with java | |
| [Service] | |
| ExecStart=/usr/local/bin/service-name-restart.sh | |
| ExecStop=/usr/local/bin/service-name-stop.sh | |
| [Install] | |
| WantedBy=default.target | |
| ######################################################################################################### | |
| # Reload daemon | |
| systemctl daemon-reload | |
| # Enable georellis-api service | |
| systemctl enable service-name.service | |
| # Start the Geotrellis API | |
| service service-name restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment