sync dev with main #7
25
README.md
25
README.md
@@ -3,7 +3,6 @@
|
||||
## overall
|
||||
you can use this as a base for your discord bot by writing your own [cogs](/cogs/), or as is.
|
||||
|
||||
|
||||
## installation
|
||||
1. clone the repo
|
||||
```bash
|
||||
@@ -22,6 +21,30 @@ CAT_API_KEY=live_abc123abc
|
||||
```
|
||||
you can then edit the [config.py](/config.py) to your liking.
|
||||
|
||||
## usage
|
||||
the bot is running when the main.py script is running.
|
||||
|
||||
### systemd service
|
||||
you can configure a systemd service for this bot.
|
||||
[systemd_service.sh](systemd_service.sh) is ONLY for systemd systems.
|
||||
|
||||
(*tested on Ubuntu 24.04*)
|
||||
|
||||
simply do:
|
||||
```
|
||||
chmod +x systemd_service.sh
|
||||
./systemd_service.sh
|
||||
```
|
||||
the systemd service will now start and auto start on reboot.
|
||||
|
||||
### updating with systemd service
|
||||
keep in mind that after updating with the systemd service enabled, you will need to restart the service.
|
||||
so the update workflow looks something like this:
|
||||
```
|
||||
git pull origin main
|
||||
sudo systemctl restart muzovkantv2
|
||||
```
|
||||
|
||||
## contacting
|
||||
if you have any feedback, contact me on github issues or/and discord. if you want to add any functions to this bot, make a PR.
|
||||
when submitting a bug report, make sure to attach the bot.log files. they generate automatically in root directory.
|
||||
|
||||
34
systemd_service.sh
Normal file
34
systemd_service.sh
Normal file
@@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
|
||||
BOT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
BOT_USER="$(whoami)"
|
||||
VENV_PYTHON="$BOT_DIR/venv/bin/python"
|
||||
SERVICE_NAME="muzovkantv2"
|
||||
|
||||
echo "creating systemd service for user '$BOT_USER' in '$BOT_DIR'..."
|
||||
|
||||
sudo tee /etc/systemd/system/$SERVICE_NAME.service > /dev/null <<EOF
|
||||
[Unit]
|
||||
Description=muzovkantv2 discord bot
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=$BOT_USER
|
||||
WorkingDirectory=$BOT_DIR
|
||||
ExecStart=$VENV_PYTHON $BOT_DIR/main.py
|
||||
Restart=on-failure
|
||||
RestartSec=5
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable $SERVICE_NAME
|
||||
sudo systemctl start $SERVICE_NAME
|
||||
|
||||
echo "done. status:"
|
||||
sudo systemctl status $SERVICE_NAME
|
||||
Reference in New Issue
Block a user