Skip to content

Automatically start at boot

bmn001 edited this page Jan 11, 2023 · 1 revision

These steps were written to work on a low-memory (512mb) Raspberry Pi Zero W.

These same general steps should work on any Linux distribution that includes systemd with only minor changes, explained below.

What does it do?

This will launch dashPanel at every boot.

dashpanel will wait its turn for a service called poolcontroller (aka: nodejs-PoolController) to launch on boot before it does.

(You'll want to set up systemd for poolController first.)

If dashPanel crashes, it'll restart itself.

Create the systemd service

First, make a systemd service for dashPanel:

sudo nano /etc/systemd/system/dashpanel.service

Into this file, paste:

[Unit]
Description=NodeJS Pool Controller Dash Panel
Documentation=https://github.com/rstrouse/nodejs-poolController-dashPanel
After=poolcontroller.service

[Service]
Environment=NODE_ENV=production
Type=simple
User=pi
WorkingDirectory=/home/pi/nodejs-poolController-dashPanel/
ExecStart=/usr/bin/node dist/app.js
Restart=on-failure
RestartSec=15s

[Install]
WantedBy=multi-user.target

Notes:

  • Change the WorkingDirectory to wherever you've put dashPanel's files.
  • Some people have node installed in /usr/bin/local/ instead of /usr/bin/ so change that line if needed.
  • If you have a more powerful machine, replace the ExecStart line with: ExecStart=/usr/bin/npm start. Again, npm may live in /usr/bin/local/, so make certain you've got the right entry there.

Enable the systemd service

After you've saved the file, reload systemd so it can see the changes:

sudo systemctl -q daemon-reload

Now enable the service to run on boot and start it right now:

sudo systemctl enable --now -q dashpanel

Troubleshooting

If nothing's coming up in a browser, view logs:

journalctl -f -u dashpanel

And start the service manually in another terminal to see what's going on:

sudo systemctl start dashpanel

Clone this wiki locally