Files
Buttonrefreshbot/SYSTEMD_SETUP.md
2025-12-25 15:30:31 -03:00

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 .env file

Installation Steps

  1. Edit the service file

    Open buttonrefreshbot.service and update the following:

    • User: Your Linux username (e.g., michael)
    • Group: Your Linux group (usually same as username)
    • WorkingDirectory: Full path to the project directory
    • EnvironmentFile: Full path to your .env file
    • ExecStart: Full path to node executable (find with which node)

    Example:

    User=michael
    Group=michael
    WorkingDirectory=/home/michael/Buttonrefreshbot
    EnvironmentFile=/home/michael/Buttonrefreshbot/.env
    ExecStart=/usr/bin/node /home/michael/Buttonrefreshbot/bot.js
    
  2. Copy the service file to systemd directory

    sudo cp buttonrefreshbot.service /etc/systemd/system/
    
  3. Reload systemd daemon

    sudo systemctl daemon-reload
    
  4. Enable the service (start on boot)

    sudo systemctl enable buttonrefreshbot.service
    
  5. Start the service

    sudo systemctl start buttonrefreshbot.service
    
  6. 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 .env file has correct permissions and contains BOT_TOKEN
  • Verify Node.js path is correct: which node
  • Check file permissions: the service user must have read access to all project files