Reference and guides to build kick ass raspberry pi projects.
View the Project on GitHub codingforentrepreneurs/Pi-Awesome
Supervisor, often called supervisord, is a simple way to manage processes that you need your pi to run. In our case, we’re using it to run a minimal python web application (flask).
sudo apt install supervisor -y
sudo service supervisor start
Be sure to enable the correct permissions on the
useror the user’s
groupso the below process can actually run.
All of your custom processes will live in the following directory:
project.supervisor.conf and put:
[program:flaskapp] user=pi directory=/home/pi/app command=/home/pi/app/bin/gunicorn wsgi:app autostart=true autorestart=true stdout_logfile=/var/log/www/flaskapp/stdout.log stderr_logfile=/var/log/www/flaskapp/stderr.log
<appname> setting here is the name of the supervisor process so we can run various commands (see step 4). Again,
flaskapp is the
user is the user you want this process to run as. We’ll stick with our default
directory: Default working directory
command: What command do we need this process to run? In my case, I’m using a Python virtual environment (ie
/home/pi/app/bin/) with gunicorn installed. This command can be any valid
bash shell command. For more on gunicorn & supervisor go here.
autostart: start on system boot (true / false)
autorestartRestart on failure (true / false)
stdoutlog file location
stderrlog file location
sudo supervisorctl reread sudo supervisorctl update
These two commands will let supervisor know of our new process (
reread) and it will run it (
sudo supervisorctl status flaskapp sudo supervisorctl start flaskapp sudo supervisorctl stop flaskapp sudo supervisorctl restart flaskapp
project.supervisor.conf from Step 3, we have the following log paths:
These logs are useful to uncover errors with your application running.