Skip to content

Run OrangeBot permanently using binaries

dejavueakay edited this page Mar 26, 2018 · 1 revision

Linux

systemd

The easiest and most reliable option to keep the bot running at all times (i. e. restart it on crashing) is using a systemd service. systemd is a start up manager that sees increasing popularity as debian and ubuntu started to default to it since some time. If you're not sure wether you're running systemd, check by running the command systemctl as root.

To add OrangeBot as a systemd service, you will need to create a new service:

nano /etc/systemd/system/orangebot.service

file with the following content:

[Unit]
Description=OrangeBot v3.0
After=network.target

[Service]
Type=simple
User=orangebot
ExecStart=/home/orangebot/orangebot/orangebot
WorkingDirectory=/home/orangebot/orangebot
Restart=on-failure

[Install]
WantedBy=multi-user.target

You'll notice the line User=orangebot. This is to let the bot itself run as a unprivileged user. We strongly advise you to do so and to not run the bot as root. As long as you use ports above 1024, you'll be fine using an unprivileged user. Change the location of the orangebot.js and the directory according to your setup.

The Restart=on-failure directive sets the service to restart if it crashed or failed. Careful: Check your logs (systemctl status orangebot.service) to ensure that no config errors happened.

Finally, let the bot start at boot:

systemctl enable orangebot.service