Ubuntu deprecated Upstart so I had to turn to Systemd for my app controls in Ubuntu 18.04. In this script I set 2 environment variables (HOME and LANG), change directory to the app directory and starts the Play Framework application
01 | # Myapp systemd script |
02 | # |
03 | # Location:/lib/systemd/system/myapp.service |
04 | # |
05 | # Useful commands: |
06 | # |
07 | # Start Myapp: systemctl start myapp.service |
08 | # Stop Myapp: systemctl stop myapp.service |
09 | # Restart Myapp: systemctl restart myapp.service |
10 | # Show status: systemctl status myapp.service |
11 | # Enable start on boot: systemctl enable myapp.service |
12 | # Disable start on boot:systemctl disable myapp.service |
13 | # |
14 | # List all services running: systemctl |
15 | # Check config: systemd-analyze verify myapp.service |
16 | # |
17 | #################################################################################### |
18 |
19 | [Unit] |
20 | Description=Job that runs my app daemon |
21 |
22 | [Service] |
23 | Type=forking |
24 | Environment=HOME=/opt/myapp/app |
25 | Environment=LANG=en_US.UTF-8 |
26 | ExecStartPre=/bin/ bash -c 'cd /opt/myapp/app' |
27 | ExecStart=/bin/ bash -c 'bin/myapp -J-Xms256M -J-Xmx768m -J-server -Dhttp.port=80 -Dconfig.file=conf/application.conf -Dlogger.file=conf/application-logger.xml' |
28 |
29 | [Install] |
30 | WantedBy=multi-user.target |
The arguments for the Play service are what I normally use for AWS. You might need other settings
Tested on Ubuntu 18.04 and Play Framework 2.3