I am trying to deploy a standalone web app by adding it as a service with Systemctl on Debian 9.9. My app works fine in standalone mode when I start it using the ./WebApp command. In the terminal when I start as a service using
systemctl start webapp
command it starts and shows me following status when I use status command:
Loaded: Loaded (from location...)
Active: Deactivating (stop-sigterm)
Process : number (code = exited)
Main PID: number (code = exited, status=0/success)
My systemctl service configuration is located in /etc/systemctl/system and looks like the following:
It looks as if the service is exiting right away … if I run ps aux I don’t see my service on that list. Has anyone used systemctl to have a standalone app restart automatically?
If it crashes i might not restart with type=forking
Be sure you need such type or create a cli application that manages/starts/stops the webapplication.
[quote=454505:@Derk Jochems]If it crashes i might not restart with type=forking
Be sure you need such type or create a cli application that manages/starts/stops the webapplication.[/quote]
Thanks for the advice. I changed my settings back to type=simple and checked journalctl, it says Started Service but it is not in the list of processes and doesn’t work… I made a bash script and tried to use that for the ExecStart parameter but it also doesn’t get started as a service with same log outputs. Not really sure, may just install something specifically for this purpose.
I start Daemons using (you can start any process from this one):
Type=forking
You can safely use this type for any process, it will NOT hold systemd from directly starting other processes as it will ignore the return code from these processes. Systemd will not accept or execute any “Restart=always” or other types of restarts for “Type=forking”.
i start the “main” applications that should be kept alive at all times using:
Type=oneshot
These kind of programs stop (hold back future processes) all futher systemd processes that are “After=” this service from being run. They
will run when this “main” application is stopped (or crashed).