2.0 KiB
2.0 KiB
Systemd Service Setup
This guide explains how to set up the Button Refresh Bot as a systemd service on Linux.
Prerequisites
- Linux system with systemd
- Node.js installed
- Bot configured with
.envfile
Installation Steps
-
Edit the service file
Open
buttonrefreshbot.serviceand update the following:User: Your Linux username (e.g.,michael)Group: Your Linux group (usually same as username)WorkingDirectory: Full path to the project directoryEnvironmentFile: Full path to your.envfileExecStart: Full path tonodeexecutable (find withwhich node)
Example:
User=michael Group=michael WorkingDirectory=/home/michael/Buttonrefreshbot EnvironmentFile=/home/michael/Buttonrefreshbot/.env ExecStart=/usr/bin/node /home/michael/Buttonrefreshbot/bot.js -
Copy the service file to systemd directory
sudo cp buttonrefreshbot.service /etc/systemd/system/ -
Reload systemd daemon
sudo systemctl daemon-reload -
Enable the service (start on boot)
sudo systemctl enable buttonrefreshbot.service -
Start the service
sudo systemctl start buttonrefreshbot.service -
Check service status
sudo systemctl status buttonrefreshbot.service
Useful Commands
- View logs:
sudo journalctl -u buttonrefreshbot.service -f - Stop service:
sudo systemctl stop buttonrefreshbot.service - Restart service:
sudo systemctl restart buttonrefreshbot.service - Disable auto-start:
sudo systemctl disable buttonrefreshbot.service
Troubleshooting
- If the service fails to start, check logs:
sudo journalctl -u buttonrefreshbot.service -n 50 - Ensure the
.envfile has correct permissions and containsBOT_TOKEN - Verify Node.js path is correct:
which node - Check file permissions: the service user must have read access to all project files