Firestorm, RPi & Docker

First time post. Bought two Pixelblaze Pico boards to control LED strings for Christmas decorations, and didn’t want to take them down. They are still hanging and lit from 6 pm to 11 pm daily.

I’ve also been playing with Firestorm since the lights look better when synced. Got it first working on Windows then got it working on RPi, but in both cases I have to use PORT=3000 yarn server, which works but stops as soon as I close the terminal window.

Trying to learn Docker, I built an image on the NodeJS base image. After much tinkering, I got it to build and run, but as soon as it runs, it immediately stops with a REPL exit event (again using the yarn server command).

I believe PM2 is supposed to help with this, but I can’t get it to work. More specifically, the command line says the server is online, but a browser can’t connect to it. Further, a netstat doesn’t show any listening port associated with the PM2 PID (image attached below).

I’ve gone through the RPi install instructions on the the github page, and the only thing that doesn’t work as specified is shown below.

pi@raspberrypi:~/Firestorm $ sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u pi --hp /home/pi
env: ‘/usr/lib/node_modules/pm2/bin/pm2’: No such file or directory
pi@raspberrypi:~/Firestorm $

Any further thoughts or advice would be most appreciated.

Thanks,
Don

i ran into this. i think pm2 got installed in a different location? try running:

which pm2

set your path to what it spits out? mine was: /usr/local/bin

hope that helps!

Seems weird to me that a “server” would exit under those circumstances.

You could try using nohup (no hangup) which should prevent it from exiting when it loses its terminal, or you could use screen or tmux to provide a long-running background terminal.

Server as in it listens on a port, not a service that runs in the background, that is what pm2 is for!

Yes, nohup, screen, etc would do the trick manually, but pm2 can restart it on boot or if it crashes, and will keep logs, etc. It also has tools for installing with various service frameworks like systemd. It’s a nice service wrapper overall.

It looks like you have something else running on port 80. In that case, try moving firestorm’s webserver to a different port.

For port 3000, try:

pm2 delete server
PORT=3000 pm2 start server.js

PM2 should pick up the environment variable as part of the service definition when it first makes the service (hence the delete first just to be sure).

You can verify that with:

#takes the numeric ID column you see in the list instead of the name
pm2 env 0

Now inside a docker instance, this would matter less, and you would probably run the server more or less directly.

Running yarn server is just a shortcut / web developer convention for node server.

Here’s a quick tutorial on dockerizing a node app:

As @basuraman had noted, pm2 was installed in /usr/local/bin. Refactoring the #run pm2 on boot command to match the correct location now has both pm2 and Firestorm running, and the browser connecting, even after the terminal is closed. This worked by using PORT=3000 pm2 start server.js.

I will look into getting the Docker running a bit later. I did notice that there is a pm2-docker command in the same /usr/local/bin folder as pm2, which might be worth looking into. But I will review that docker tutorial to try to understand what’s actually needed.

Thank for all the input

FWIW, here is the Dockerfile I tried before getting pm2 working

FROM node:17-bullseye

WORKDIR /app

COPY package*.json ./

COPY yarn.lock ./

RUN yarn install

COPY . .

ENV PORT=3000

EXPOSE 3000

CMD yarn server

Also tried CMD [ "yarn", "server" ]