- Create service named employee using vi command
sudo vim /etc/systemd/system/employee.service
- Copy paste the following content into the file and make sure to change the ExecStart command arguments
[Unit] Description=Employee Spring Boot application service [Service] User=ubuntu ExecStart=/usr/bin/java -Dspring.profiles.active=prod -Dusername="admin" -Dpassword="Password129388" -jar /home/ubuntu/Employee/target/employee-0.0.1-SNAPSHOT.jar ExitStatus=143 TimeoutStopSec=10 Restart=on-failure RestartSec=5 [Install] WantedBy=multi-user.target
- Enable the service
sudo systemctl enable employee
- Start the service
sudo systemctl start employee
- Reload system daemon
sudo systemctl daemon-reload
- Check the service status
sudo systemctl status employee
- Check service logs using the following command
sudo journalctl -u employee.service --no-pager
Created
September 27, 2019 04:16
-
-
Save pavankjadda/972dcde09463a21d8c4727ab1f6017dd to your computer and use it in GitHub Desktop.
How to create Spring Boot app as Ubuntu service?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On Ubuntu 20.04, the systemd does not recognize
ExitStatus
key with error message:Unknown key name 'ExitStatus' in section 'Service', ignoring.
. In this case, you might be changeExitStatus
toSuccessExitStatus
.