Supervisor helps you keep programs running on your Raspberry Pi. It restarts them if they stop and makes managing many programs easy.
Process management with supervisor in Raspberry Pi
[program:your_program_name] command=python3 /path/to/your_script.py autostart=true autorestart=true stderr_logfile=/var/log/your_program.err.log stdout_logfile=/var/log/your_program.out.log
program: This names your program in Supervisor.
command: The command to run your program.
[program:hello_world] command=python3 /home/pi/hello.py autostart=true autorestart=true stderr_logfile=/var/log/hello.err.log stdout_logfile=/var/log/hello.out.log
[program:web_server] command=/usr/bin/node /home/pi/server.js autostart=true autorestart=true stderr_logfile=/var/log/web_server.err.log stdout_logfile=/var/log/web_server.out.log
This example shows how to set up Supervisor to manage a Python script that blinks an LED on your Raspberry Pi. It will start automatically and restart if it stops.
[program:blink_led] command=python3 /home/pi/blink_led.py autostart=true autorestart=true stderr_logfile=/var/log/blink_led.err.log stdout_logfile=/var/log/blink_led.out.log # To use this: # 1. Save this config as /etc/supervisor/conf.d/blink_led.conf # 2. Run 'sudo supervisorctl reread' and 'sudo supervisorctl update' # 3. Start the program with 'sudo supervisorctl start blink_led' # 4. Check status with 'sudo supervisorctl status blink_led'
After adding or changing Supervisor configs, always run sudo supervisorctl reread and sudo supervisorctl update to apply changes.
Logs help you see what your program is doing or why it stopped. Check the log files if something goes wrong.
You can control programs with sudo supervisorctl start|stop|restart program_name.
Supervisor keeps your Raspberry Pi programs running smoothly by restarting them if they stop.
You write simple config files to tell Supervisor what to run and how.
Use Supervisor commands to manage your programs easily from the terminal.