Raspberri Pi: NodeJS Automatic Start after Reboot

For those who might not be aware of how to make services such as the HubConnect Proxy run automatically on a Raspberry Pi:

  1. Create a file "hcproxy.service":
    sudo nano /etc/systemd/system/hcproxy.service

  2. Copy the text below into the editor (change the WorkingDirectory line to match where you installed the proxy code)

	
[Unit] Description=HubConnect Proxy Service After=network.target [Service] WorkingDirectory=/var/hubconnect ExecStart=/usr/bin/node proxy.js Restart=on-failure User=pi [Install] WantedBy=multi-user.target
  1. Exit nano with the following commands
    ctrl-X, Y, return

  2. Run the following commands
    sudo systemctl daemon-reload
    sudo systemctl enable hcproxy.service
    sudo service hcproxy start

The hcproxy will start on boot, and it will automatically be restarted if it fails.

You can check the status of the proxy with this command:
sudo service hcproxy status

All of the output is automatically logged to /var/log/daemon.log - you can watch it with this command:
tail -f /var/log/daemon.log