PlottyBot Development Documentation - CodeClubLuxembourg/plottybot-toolkit-web GitHub Wiki
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.
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.
- This command monitors and rebuilds
-
Run
scratch-gui
in development mode:cd path/to/scratch-gui npm start
- This launches
scratch-gui
usingwebpack-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.
- This launches
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.
- Build
-
Automate with pm2:
- If you want
scratch-vm
andscratch-gui
to start automatically on server reboot,pm2
provides process management and reliability. - Start
http-server
forscratch-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 throughpm2
.
- If you want
- To list and check the status of running processes under
pm2
:pm2 status
- View specific logs for debugging:
pm2 logs scratch-gui
-
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>
- Check the environment, open files, and command details for any running process:
ps -p <PID> -o cmd sudo lsof -p <PID>
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. |