Python Server - CodeClubLuxembourg/plottybot-toolkit-web GitHub Wiki

Python Server Functionality

Starting at Boot via /etc/rc.local

The Python server for PlottyBot is configured to start automatically at boot. This is achieved by modifying the /etc/rc.local file.

Key Components

  • pigpiod: The Raspberry Pi GPIO daemon starts at boot to manage GPIO operations.
  • Logging: Standard error output from plottybot.py is redirected to /var/log/plottybot.stderr.log for easier debugging.
  • Screen Session: The Python server runs in a detached screen session named "plottybot."

Code in /etc/rc.local

/usr/bin/pigpiod
rm /var/log/plottybot.stderr.log || true
/usr/bin/screen -S plottybot -dm sh -c "/usr/local/bin/plottybot.py 2>/var/log/plottybot.stderr.log"

Debugging and Management

Viewing Logs

  • The log file is located at /var/log/plottybot.stderr.log.

Accessing the Screen Session

  • Use the command sudo screen -r plottybot to re-attach to the screen session.

Detaching

  • To detach from a screen session without terminating it, press the following key combination: Ctrl + A followed by D

Stopping the Service

  • To stop the Python server, find the PID with:
  ps aux | grep plottybot.py
  • Then use:
  kill <PID>

or:

  sudo kill <PID>

Starting the Service

  • To restart the Python server, you can reboot the system or run the screen command manually.

Navigation

⚠️ **GitHub.com Fallback** ⚠️