-
Notifications
You must be signed in to change notification settings - Fork 0
Systemd
On this page, you will learn how to set up a simple systemd service to automatically start your bot when your machine starts and how to setup logging
NOTE: This tutorial is only for Linux
If you've used Linux before you might have also interacted with systemd in one form or another
For example, you might have seen this screen when booting up
All of these are systemd services
You might have also used service
or systemctl
e.g.
sudo service apache2 status
sudo systemctl status apache2.service
All the installed services are located inside of /etc/systemd/system
You can use the editor of your choice to create a file called something like yourBot.service
e.g. sudo nano /etc/systemd/system/yourBot.service
Here you can just paste in the following text:
[Unit]
Description=Your Bot
After=network.target
[Service]
Type=simple
User=<user>
ExecStart=<file>
[Install]
WantedBy=multi-user.target
You will need to replace with a user and with the path to the pixiBot
file
If you now use sudo service pixiBot start
you should see your bot coming online
You can also see the status of your bot with sudo service pixiBot status
Your bot will now also automatically start when your machine boots up
You can prevent this by using
sudo systemctl disable yourBot.service
You can also configure the bot to log in a special format
To do this all you need to do is put this in your Bot's appsettings.json
{
...
"Logging": {
"Console": {
"FormatterName": "Systemd"
}
}
...
}