Deploy on Linux

This tutorial will guide you through the process of deploying discordgsm on your Linux server.

Requirements

Before deployment, you need to prepare the following items.

  • Python 3.8+
Get Started

This tutorial will have you deploying discordgsm on Linux server.

1. Create a new user

Create a user named discordgsm and switch to that user.

sudo adduser discordgsm
su - discordgsm

2. Clone the repository

Clone GameServerMonitor repository by the following command.

git clone https://github.com/DiscordGSM/GameServerMonitor
cd GameServerMonitor
git checkout tags/$(git describe --tags)

or download manually: Github

3. Create a Virtual Python Environment

The following commands will create a new virtual environment.

virtualenv venv

4. Activate the Environment

Now that we have a virtual environment, we need to activate it.

source venv/bin/activate

After you activate the environment, your command prompt will be modified to reflect the change.

5. Install Python dependencies and packages

The following commands will download the necessary dependencies and packages.

pip install -r requirements.txt

6. Configure the environment variables

Copy .env.example to .env

cp .env.example .env

Edit .env with your favourite editor. Learn more: DevOps Guide: Environment Variables

nano .env

7. Add the bot to your server

The following commands will start the discord bot.

python main.py

View the console output and click the bot invite link to add the bot to your server.

8. Create a service

Press Ctrl+C to exit the process, then create a service file.

sudo nano /etc/systemd/system/discordgsm.service

Copy and paste the following content and save.

/etc/systemd/system/discordgsm.service
[Unit]
Description=Discord Game Server Monitor
After=network.target

[Service]
User=discordgsm
Group=discordgsm
WorkingDirectory=/home/discordgsm/GameServerMonitor
ExecStart=/home/discordgsm/GameServerMonitor/venv/bin/python main.py
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

9. Reload the service daemon

Reload systemd manager configuration.

sudo systemctl daemon-reload

10. Enable and start the service

Enable automatically get it to start on boot and start the service.

sudo systemctl enable discordgsm.service
sudo systemctl start discordgsm.service

11. View status of the service

sudo systemctl status discordgsm.service

12. View the service console log (Optional)

sudo journalctl -u discordgsm.service -f

13. Congratulations! 🎉

DiscordGSM has deployed.

Update

This tutorial will update the application to the latest release version.

1. Activate the Environment

The following commands will change the directory to GameServerMonitor and activate the environment.

cd GameServerMonitor
source venv/bin/activate

2. Pull the repository

The following commands will pull the latest version.

git checkout tags/$(git describe --tags)

3. Install Python dependencies and packages

The following commands will download and update the necessary dependencies and packages.

pip install -r requirements.txt

4. Restart the service

The following commands will restart the service.

sudo systemctl restart discordgsm.service

5. Congratulations! 🎉

DiscordGSM has updated.