How to start a java springboot application as a sytem service in linux

176 Views Asked by At

I am trying to create a systemd service for a spring boot application, servie is creating but the status shows as follows,

● vehicle_service-0.1.0.service - vehicle micro service
   Loaded: loaded (/etc/systemd/system/vehicle_service-0.1.0.service; enabled; vendor preset: disabled)
   Active: activating (auto-restart) (Result: exit-code) since Mon 2022-09-19 05:30:50 UTC; 10s ago
  Process: 23815 ExecStart=/home/Manoj/vehicle-servive/build/libs/start.sh (code=exited, status=203/EXEC)
 Main PID: 23815 (code=exited, status=203/EXEC)

Sep 19 05:30:50 jenkins systemd[1]: Unit vehicle_service-0.1.0.service entered failed state.
Sep 19 05:30:50 jenkins systemd[1]: vehicle_service-0.1.0.service failed.
2

There are 2 best solutions below

0
Amir On

I suggest you use docker-compose because when a docker container is up if you reboot system it is still up

0
harl On

try add #!/bin/sh this to the top of the script /home/Manoj/vehicle-servive/build/libs/start.sh