'How do I start an app when the system (Ubuntu) starts?
I have an app which I want to start when the server starts. I also want the app to automatically restart if it ever crashed and stops. My understanding is that I need to setup a systemd service for this. This is what I have done so far:
/etc/systemd/system/multi-user.target.wants/userapp.service
[Unit]
Description=User App
After=network.target
[Service]
User=user
WorkingDirectory=/home/user
ExecStart=/home/user/start.sh
KillMode=process
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=what
Restart=on-failure
RestartSec=60
[Install]
WantedBy=multi-user.target
start.sh
#!/bin/bash
echo "Starting UserApp" | logger
./userapp
The problem is the service starts, no errors, then the service immediately stops, and the app. The start.sh and userapp are both chmod +x 755
Can anyone help me understand whats wrong?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
