Raspberry PI / Linux / Debian – Use supervisor to keep process UP (PHP / Python etc..)

Raspberry PI / Linux / Debian – Use supervisor to keep process UP (PHP / Python etc..)

Install supervisor

sudo apt-get install supervisor

Create a new app.conf :

sudo nano /etc/supervisor/conf.d/app.conf
; Python APP
[program:app]
command= python /home/app/app.py
autostart=true
autorestart=true

; PHP APP
[program:app]
command=php /home/app/app.php
autostart=true
autorestart=true

Print status of processes :

sudo supervisorctl status
app1                         RUNNING   pid 7898, uptime 3:07:14
app2                         RUNNING   pid 7899, uptime 2:04:14