-
Notifications
You must be signed in to change notification settings - Fork 93
Running Dasher on a Raspberry Pi at startup
If you would like your Pi to start up Dasher automatically on reboot, you will need to install an "init script". This free init script template is a great place to start.
For example, first go to the raw template file and select the whole page and copy it to your clipboard. Then connect to your pi:
ssh pi.local
sudo nano /etc/init.d/dasher
[paste clipboard contents]
Now you'll need to modify the top of the file. Here's an example:
#!/bin/sh
### BEGIN INIT INFO
# Provides: dasher
# Required-Start: $network $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
dir="/home/pi/dasher"
cmd="npm run start"
user="root"
This assumes you have installed Dasher to /home/pi/dasher
.
Now type CTRL+o to save, then enter, then CTRL+x to exit. Now change the file permissions and "install" the script:
sudo chmod 755 /etc/init.d/dasher
sudo update-rc.d dasher defaults
It should now run when your Pi reboots. You can also start it up manually like this:
sudo /etc/init.d/dasher start
To view the running logs, you can tail
the output log or error log:
tail -f /var/log/dasher.log
tail -f /var/log/dasher.err
to create a systemd service, run the following commands:
sudo nano /etc/systemd/system/dasher.service
- copy and paste the code below - save with CTRL+O.
[Unit]
Description=Dasher
After=network.target
[Service]
Type=simple
#user with access to dasher files
User=root
WorkingDirectory=/home/pi/dasher
#use command "which npm" to determine correct location of NPM
ExecStart=/usr/local/bin/npm run start
[Install]
WantedBy=multi-user.target
sudo systemctl --system daemon-reload
sudo systemctl enable dasher
sudo systemctl start dasher
The service should be running up now and startup on reboot.
To check if everthing is working correctly use:
sudo journalctl -f -u dasher