Hello, In this post we will be seeing how to host a discord.py bot 24/7 on a ubuntu server. This post assumes that you have already coded your discord bot.
These are some of the simple steps to keep running your bot 24/7
SSH into your server using putty or any other you prefer
Run
sudo apt-get install supervisor
to install supervisor-ctlThen Run This command to make a new config
sudo nano /etc/supervisor/conf.d/yourproject.conf
-
Then type the following
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters[program:yourproject] directory=/home/gamic/projects/gamic/ command=/usr/bin/python /home/gamic/projects/gamic/bot.py user=root autostart=true autorestart=true stopasgroup=true killasgroup=true stderr_logfile=/var/log/gamic/flaskblog.err.log stdout_logfile=/var/log/gamic/flaskblog.out.log Run
sudo supervisorctl restart all
to restart the service with new configurationThat's it now you can see your bot online 24/7 and even if you restart your server your bot will restart and come online
Some important notes
the place where I have mentioned your project or project please change it to your desired name
-
Also please change the following to according to your name
- directory
- stderr_logfile
- stdout_logfile
- user
P.S:- Vultr(Get a $100 credit by registering using this link) is a good hosting choice if you're looking for one
Top comments (4)
Was that disclaimer supposed to have a link??
Also few typos. . .
I'm sorry will modify it
This is incomplete. At step 4, you instruct readers to type the following, but there's nothing there to type.
This is incomplete. At step 4, you instruct readers to type the following, but there's nothing there to type.