This repository was archived by the owner on Dec 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Deploy systemd
Brian Mitchell edited this page Aug 13, 2019
·
2 revisions
weatherBot can be configured to run as a systemd service on supported Linux systems.
The following is a basic example, but for a more secure installation, you will want to configure the service to run under its own user and store the tokens and secrets in a directory that is not world readable.
- Make sure a supported version of Python is installed on the system.
python3 -V- Clone the repository.
git clone https://github.com/BrianMitchL/weatherBot.git- Install dependencies.
# in the weatherBot directory
pip3 install -r requirements.txt- Configure the bot
- Enter tokens/secrets into
keys.py - Customize strings in
string.yml - Configure
weatherBot.conf
- Create the systemd service. Make sure this is owned by
root.
sudo touch /etc/systemd/system/weatherBot.serviceEdit the service to contain the following
[Unit]
Description=weatherBot
[Service]
Type=simple
WorkingDirectory=/path/to/weatherBot/GitHub/clone
ExecStart=/usr/bin/python3 weatherBot.py weatherBot.conf
# restart the service if it crashes (watch out for rate limiting and repeated crashing)
# Restart=always
[Install]
WantedBy=multi-user.target- Enable and start the service.
# start the service at boot
sudo systemctl enable weatherBot.service
# start the service
sudo systemctl start weatherBot.serviceYou can check the status by running
sudo systemctl status weatherBot.serviceIf changes are made to the weatherBot.service file, you will need to reload the service for changes to take effect.
sudo systemctl daemon-reload