• Create systemd service units for zend and tracker
  • Stop zend
  • Start zend and zentracker services
  • Get status of zend and zentracker services
  • Enable units at boot




DescriptionCommand
1

Create a systemd unit file for zend, copy and paste the entire block of text


echo \
"[Unit]
Description=Zen daemon

[Service]
User=$USER
Type=forking
ExecStart=/usr/bin/zend -daemon -pid=$HOME/.zen/zend.pid
PIDFile=$HOME/.zen/zend.pid
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target" | sudo tee /lib/systemd/system/zend.service


2Create a systemd unit file for the Node Tracker, copy and paste the entire block of text


echo \
"[Unit]
Description=Zen node daemon installed on ~/nodetracker/

[Service]
User=$USER
Type=simple
WorkingDirectory=$HOME/nodetracker/
ExecStart=$(which node) $HOME/nodetracker/app.js
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target" | sudo tee /lib/systemd/system/zentracker.service


3

Stop zend and apply ownership to the non-root user of all files created since part 6.8



zen-cli stop && sleep 30 && sudo chown -R $USER:$USER ~/




4Test the unit files


sudo systemctl start zend zentracker


5

Check the status of both zend and the tracker, both should return active (running). If the status doesn't send you back to a command prompt, exit the status details by pressing CTRL + c



sudo systemctl status -n 0 zend zentracker



zenops@node01:~$ sudo systemctl status -n 0 zend zentracker
zend.service - Zen daemon
Loaded: loaded (/lib/systemd/system/zend.service; disabled; vendor preset: enabled)
Active: active (running) since Thu 2018-05-24 22:31:30 EDT; 34s ago
Process: 21612 ExecStart=/usr/bin/zend -daemon -pid=/home/zenops/.zen/zend.pid (code=exited, status=0/SUCCESS)
Main PID: 21615 (zend)


Tasks: 16


Memory: 810.0M


CPU: 18.963s


CGroup: /system.slice/zend.service


└─21615 /usr/bin/zend -daemon -pid=/home/zenops/.zen/zend.pid

zentracker.service - Zen node daemon installed on ~/nodetracker/

Loaded: loaded (/lib/systemd/system/zentracker.service; disabled; vendor preset: enabled)
Active: active (running) since Thu 2018-05-24 21:34:27 EDT; 1h 1min ago
Main PID: 19648 (node)


Tasks: 10


Memory: 38.9M


CPU: 4.110s


CGroup: /system.slice/zentracker.service


└─19648 /usr/local/bin/node /home/zenops/nodetracker/app.js


6

Follow the logs from the tracker to check for the first challenge being received, exit by pressing CTRL + c



sudo journalctl -fu zentracker


7If both systemd unit files work correctly (showing active and running in step 6) enable them at boot


sudo systemctl enable zend zentracker



Part 9 of 11 - Configure Services