PlottyBot Development Documentation - CodeClubLuxembourg/plottybot-toolkit-web GitHub Wiki

PlottyBot Development Documentation


sudo screen -r plottybot

sudo screen -r plottybot_scratch

Overview

The PlottyBot project integrates a customized Scratch interface to control an XY plotter (PlottyBot). The setup consists of two main components, scratch-vm and scratch-gui, which enable interactive drawing commands through Scratch, targeting educational and interactive learning environments.


Setup and Workflow

1. Development Mode Setup

To run scratch-vm and scratch-gui for development, you need two separate terminal sessions:

  • Run scratch-vm in watch mode: cd path/to/scratch-vm npm run watch
    • This command monitors and rebuilds scratch-vm for any code changes, allowing rapid iteration and testing.
  • Run scratch-gui in development mode: cd path/to/scratch-gui npm start
    • This launches scratch-gui using webpack-dev-server, making it accessible on a specified port (default: 8601) with live reloading for frontend changes.
    • Access it in a browser via http://<server-ip>:8601/ to test PlottyBot interactions.

2. Production Mode Setup (Optional)

For a persistent, production-ready setup, especially if intending to keep scratch-gui available after reboots:

  • Build and Serve:
    • Build scratch-gui to create static assets: cd path/to/scratch-gui npm run build
    • Use http-server or a similar static server to serve the build output.
  • Automate with pm2:
    • If you want scratch-vm and scratch-gui to start automatically on server reboot, pm2 provides process management and reliability.
    • Start http-server for scratch-gui: pm2 start http-server --name "scratch-gui" -- path/to/scratch-gui/build -p 8601
    • To make the configuration persistent, use: pm2 save
    • This setup ensures that scratch-gui is automatically restarted after reboots, with logs and CPU monitoring available through pm2.

Troubleshooting and Important Commands

Checking Process Status

  • To list and check the status of running processes under pm2: pm2 status
  • View specific logs for debugging: pm2 logs scratch-gui

Common Errors and Fixes

  • Port Conflicts: The EADDRINUSE error indicates that the specified port is already in use. Identify the conflicting process: sudo lsof -i :8601
  • Kill Conflicting Process (if necessary): sudo kill -9 <PID>

Monitoring Specific Processes

  • Check the environment, open files, and command details for any running process: ps -p <PID> -o cmd sudo lsof -p <PID>

Summary of Commands

Purpose Command
Start scratch-vm in watch mode npm run watch (in scratch-vm directory)
Start scratch-gui in dev mode npm start (in scratch-gui directory)
Build scratch-gui for production npm run build (in scratch-gui directory)
Serve scratch-gui production build http-server -p 8601 path/to/scratch-gui/build
Start scratch-gui with pm2 pm2 start http-server --name "scratch-gui" -- path/to/scratch-gui/build -p 8601
List and manage processes with pm2 pm2 status, pm2 logs, pm2 restart, etc.
⚠️ **GitHub.com Fallback** ⚠️