Skip to content

Autorun on boot

Thomas T. Jarløv edited this page Feb 23, 2019 · 2 revisions

There are several ways to startup NimHA on boot. You can use .bashrc, crontab, systemctl, etc.

Systemctl

Service file

Create a new file called nimha.service inside /lib/systemd/system/nimha.service

sudo nano /lib/systemd/system/nimha.service

Insert the data below. Adjust the paths and remove the comments.

[Unit]
Description=nimha
After=network-online.target # Depending if you want the network to run first
Wants=mosquitto.service # Mosquitto MQTT broker needs to be up an running

[Service]
User=user # MODIFY - Insert your username
Type=simple
WorkingDirectory=/home/<user>/.nimble/pkgs/nimha-0.1.0/ # MODIFY
ExecStart=/home/<user>/.nimble/bin/nimha # MODIFY
Restart=always
RestartSec=15

[Install]
WantedBy=multi-user.target

Enable auto start and start it:

sudo systemctl enable nimha
sudo systemctl start nimha
sudo systemctl status nimha

View log file

sudo journalctl -u nimha