Daemonzing a Flask Server

So I wrote about Lights out recently. I decided that I wanted to have the server run when the device boots up (in this case it's a Ubuntu running Beaglebone Black). So I decided to look into supervisor for that. I've worked with supervisor before, but now it was a little different.

Flask code can be seen here (and the scripts)

Now the time is to write a supervisord conf so that we can provide parameters to autostart and start if the daemon crashes. Here's my conf for the server.

[program:lightmanager]
command=/var/www/server/venv/bin/python /var/www/server/start.py  
autostart=true  
autorestart=true  
stderr_logfile=/var/log/lightmanager.error.log  
stdout_logfile=/var/log/lightmanager.access.log  

This will auto execute the command at machine boot and restart if it crashes.

Really interesting that supervisorctl command actually shows you the daemons that were running. I have another daemon that symlinks the gpio in /sys/. However, it is entirely the same as above, so no point repeating it. I bet I could daemonize almost everything.