Service files

From XPUB & Lens-Based wiki

Making a systemd service file



$ sudo nano /etc/systemd/system/myflaskapp.service
Description=<a description of your application>

WorkingDirectory=<path to your app>
ExecStart=<app start command>


When the service file is new or changed, you need (one time) to:

$ sudo systemctl daemon-reload

Then you can:

$ sudo systemctl start myflaskapp
$ sudo systemctl status myflaskapp
$ sudo systemctl restart myflaskapp
$ sudo systemctl stop myflaskapp

Then finally when you see that start works (checking status, checking that it actually is running , etc)

$ sudo systemctl enable myflaskapp

Will make the "service" auto start when the pi restarts.

To view the log file (errors):

$ sudo journalctl -u myflaskapp -f