0
0
Raspberry Piprogramming~30 mins

Process management with supervisor in Raspberry Pi - Mini Project: Build & Apply

Choose your learning style9 modes available
Process Management with Supervisor on Raspberry Pi
📖 Scenario: You have a Raspberry Pi running several small programs. You want to make sure these programs start automatically and keep running even if they crash. Supervisor is a tool that helps manage these programs easily.
🎯 Goal: You will create a Supervisor configuration file to manage a simple Python script as a process. You will set up the configuration, start Supervisor, and check the process status.
📋 What You'll Learn
Create a Supervisor configuration file for a Python script
Set up a program section with the correct command and settings
Reload Supervisor to apply the configuration
Check the status of the managed process
💡 Why This Matters
🌍 Real World
Supervisor helps keep important programs running on devices like Raspberry Pi without manual restarts.
💼 Career
Understanding process management with Supervisor is useful for system administrators and developers managing services on Linux-based systems.
Progress0 / 4 steps
1
Create a simple Python script
Create a Python script called hello.py that prints "Hello from Supervisor!" and then waits for 60 seconds. Write exactly these two lines in the script.
Raspberry Pi
Need a hint?

Use print() to show the message and time.sleep(60) to pause.

2
Create Supervisor configuration file
Create a Supervisor configuration file named hello.conf with a [program:hello] section. Set command=python3 /home/pi/hello.py, autostart=true, and autorestart=true exactly as shown.
Raspberry Pi
Need a hint?

The file must start with [program:hello] and include the exact command and options.

3
Reload Supervisor to apply configuration
Run the command sudo supervisorctl reread followed by sudo supervisorctl update to reload Supervisor and apply the new hello.conf configuration.
Raspberry Pi
Need a hint?

Use these two commands exactly to reload Supervisor's configuration.

4
Check the status of the managed process
Run the command sudo supervisorctl status hello to check if the hello program is running under Supervisor.
Raspberry Pi
Need a hint?

This command shows if the program is running or stopped.