Bird
Raised Fist0
Raspberry Piprogramming~20 mins

Process management with supervisor in Raspberry Pi - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Supervisor Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate
1:30remaining
What is the output of this Supervisor status command?
You run supervisorctl status on your Raspberry Pi. What output will you see if the service myapp is running and has been up for 5 minutes?
Raspberry Pi
myapp                          RUNNING   pid 1234, uptime 0:05:00
Amyapp RUNNING pid 1234, uptime 0:05:00
Bmyapp STARTING pid 1234, uptime 0:00:10
Cmyapp FATAL Exited too quickly
Dmyapp STOPPED Not running
Attempts:
2 left
💡 Hint
Look for the status that means the program is active and running.
🧠 Conceptual
intermediate
1:00remaining
Which file does Supervisor use to configure managed programs?
On a Raspberry Pi, where do you usually define the programs Supervisor should manage?
A/usr/bin/supervisord
B/var/log/supervisor.log
C/etc/supervisor/conf.d/*.conf
D/home/pi/.supervisorrc
Attempts:
2 left
💡 Hint
Think about configuration files ending with .conf.
🔧 Debug
advanced
2:00remaining
Why does this Supervisor program fail to start?
Given this Supervisor program config snippet, why does the program fail to start? [program:myapp] command=/home/pi/myapp/start.sh user=pi autostart=true autorestart=true The start.sh script is executable and works when run manually.
Raspberry Pi
[program:myapp]
command=/home/pi/myapp/start.sh
user=pi
autostart=true
autorestart=true
AThe command path is incorrect; it should be absolute to /usr/bin/start.sh
BThe start.sh script requires environment variables not set by Supervisor
CThe user 'pi' does not have permission to run Supervisor
DSupervisor cannot run shell scripts directly; it needs a Python script
Attempts:
2 left
💡 Hint
Think about environment differences between manual run and Supervisor run.
📝 Syntax
advanced
1:30remaining
Which Supervisor config snippet correctly restarts a program on failure?
Choose the correct Supervisor program config to restart myapp automatically if it crashes.
A
[program:myapp]
command=/home/pi/myapp/run.sh
autostart=true
restart_on_failure=true
B
[program:myapp]
command=/home/pi/myapp/run.sh
autostart=false
autorestart=false
C
[program:myapp]
command=/home/pi/myapp/run.sh
restart=always
D
[program:myapp]
command=/home/pi/myapp/run.sh
autostart=true
autorestart=true
startretries=3
Attempts:
2 left
💡 Hint
Look for the official Supervisor keys for restarting.
🚀 Application
expert
2:00remaining
How to reload Supervisor config without stopping running programs?
You updated a program config file in /etc/supervisor/conf.d/ on your Raspberry Pi. Which command reloads the config and applies changes without stopping running programs?
Asupervisorctl reread && supervisorctl update
Bsupervisorctl restart all
Csystemctl restart supervisor
Dsupervisorctl reload
Attempts:
2 left
💡 Hint
One command reads new configs, the other applies them.

Practice

(1/5)
1. What is the main purpose of using supervisor on a Raspberry Pi?
easy
A. To update the Raspberry Pi operating system
B. To install new software packages
C. To manage network connections
D. To automatically restart programs if they stop unexpectedly

Solution

  1. Step 1: Understand Supervisor's role

    Supervisor is a tool designed to keep programs running by restarting them if they crash or stop.
  2. Step 2: Compare options with Supervisor's function

    Updating the operating system, managing network connections, or installing software packages are tasks Supervisor does not do.
  3. Final Answer:

    To automatically restart programs if they stop unexpectedly -> Option D
  4. Quick Check:

    Supervisor restarts stopped programs = B [OK]
Hint: Supervisor restarts crashed programs automatically [OK]
Common Mistakes:
  • Confusing Supervisor with system update tools
  • Thinking Supervisor manages network or installs software
  • Assuming Supervisor only monitors without restarting
2. Which of the following is the correct syntax to start Supervisor after installing it on Raspberry Pi?
easy
A. start supervisor
B. supervisor start
C. sudo systemctl start supervisor
D. sudo start supervisor

Solution

  1. Step 1: Recall Supervisor service management

    Supervisor runs as a system service managed by systemctl on modern Raspberry Pi OS.
  2. Step 2: Identify correct command syntax

    The correct command to start Supervisor service is sudo systemctl start supervisor. Other options are incorrect or incomplete.
  3. Final Answer:

    sudo systemctl start supervisor -> Option C
  4. Quick Check:

    Use systemctl to start services = A [OK]
Hint: Use 'sudo systemctl start supervisor' to start service [OK]
Common Mistakes:
  • Omitting sudo and getting permission errors
  • Using incomplete or wrong command like 'supervisor start'
  • Confusing with older init.d commands
3. Given this Supervisor config snippet:
[program:myapp]
command=python3 /home/pi/myapp.py
autostart=true
autorestart=true
stderr_logfile=/var/log/myapp.err.log
stdout_logfile=/var/log/myapp.out.log

What happens if myapp.py crashes?
medium
A. Supervisor restarts myapp.py automatically
B. Supervisor stops and does not restart myapp.py
C. Supervisor logs the error but does not restart
D. Supervisor deletes the log files

Solution

  1. Step 1: Analyze config options autostart and autorestart

    autostart=true means program starts with Supervisor; autorestart=true means it restarts if it crashes.
  2. Step 2: Understand Supervisor behavior on crash

    With autorestart=true, Supervisor will restart myapp.py automatically after a crash.
  3. Final Answer:

    Supervisor restarts myapp.py automatically -> Option A
  4. Quick Check:

    autorestart=true means auto restart = C [OK]
Hint: autorestart=true means program restarts on crash [OK]
Common Mistakes:
  • Thinking logs are deleted on crash
  • Assuming Supervisor only logs errors without restart
  • Confusing autostart with autorestart
4. You wrote this Supervisor config but your program does not start automatically:
[program:myapp]
command=python3 /home/pi/myapp.py
autostart=false
autorestart=true

What is the problem?
medium
A. autostart is set to false, so program won't start on Supervisor launch
B. command syntax is incorrect
C. autorestart should be false to start program
D. Log files are missing

Solution

  1. Step 1: Check autostart setting

    autostart=false means Supervisor will NOT start the program automatically when it launches.
  2. Step 2: Understand effect on program start

    Because autostart is false, the program must be started manually; this explains why it does not start automatically.
  3. Final Answer:

    autostart is set to false, so program won't start on Supervisor launch -> Option A
  4. Quick Check:

    autostart=false means no auto start = D [OK]
Hint: autostart=false disables automatic program start [OK]
Common Mistakes:
  • Confusing autorestart with autostart
  • Assuming command syntax is wrong without checking
  • Thinking missing logs stop program start
5. You want Supervisor to run two programs, app1.py and app2.py, but only restart app2.py if it crashes. Which config setup is correct?
hard
A. [program:app1] command=python3 /home/pi/app1.py autostart=false autorestart=true [program:app2] command=python3 /home/pi/app2.py autostart=true autorestart=false
B. [program:app1] command=python3 /home/pi/app1.py autostart=true autorestart=false [program:app2] command=python3 /home/pi/app2.py autostart=true autorestart=true
C. [program:app1] command=python3 /home/pi/app1.py autostart=true autorestart=true [program:app2] command=python3 /home/pi/app2.py autostart=false autorestart=true
D. [program:app1] command=python3 /home/pi/app1.py autostart=false autorestart=false [program:app2] command=python3 /home/pi/app2.py autostart=false autorestart=false

Solution

  1. Step 1: Identify requirements for app1 and app2

    app1 should run automatically but NOT restart on crash (autorestart=false). app2 should run automatically and restart on crash (autorestart=true).
  2. Step 2: Match config options to requirements

    [program:app1] command=python3 /home/pi/app1.py autostart=true autorestart=false [program:app2] command=python3 /home/pi/app2.py autostart=true autorestart=true sets autostart=true for both, autorestart=false for app1, and autorestart=true for app2, matching the requirements exactly.
  3. Final Answer:

    [program:app1] command=python3 /home/pi/app1.py autostart=true autorestart=false [program:app2] command=python3 /home/pi/app2.py autostart=true autorestart=true -> Option B
  4. Quick Check:

    app1 no restart, app2 restart = A [OK]
Hint: Set autorestart true only for programs needing auto-restart [OK]
Common Mistakes:
  • Setting autostart false prevents program from running automatically
  • Confusing autostart and autorestart settings
  • Setting autorestart true for programs that shouldn't restart
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard