Is there a way to make a site to display the uptime and output of a long running python program

Viewed 233

I have multiple discord bots that I make and host for people. I was looking to make a page on my website to show the stdout, stderr and uptime of each of my bots on this page.

Each bot runs in a separate "screen", which is created using the screen package as provided: here I can easily pipe the stdout and stderr to any file if needed.

I am running ubuntu 18.04 and I personally own the machine so there are little to no limitations on what I am able to do with it.

My python version is: Python 3.6.4

The discord bot API is discord.py v1.4.1 (rewrite) as seen: here

v1.5.0 is newly released so I'm waiting to update to it, while checking the changelog I didn't notice anything that could affect this project so there should be no issues

I am not concerned about the layout of the website as all styling will be done later, I just want to see if there is a way that I can take the values specified above and put them in a web page. I have some experience in js and am quite experienced in theoretical knowledge, so not knowing exactly how to code in it shouldn't be too much of a problem (I hope)

I have searched around for a while but couldn't find any solutions. Hope someone here can help :)

1 Answers

Uptime monitoring websites is not directly a feature of discord.py, because it would add a whole layer of complexity .

You can write your own HTTP web server to serve your website's content (ie. to keep track of uptime, downtime, etc. by yourself ), but that would probably end up being overly complicated.

If you don't want this extreme complexity, you can use ⚒️ UptimeRobot (not affiliate link) to create a status page for you. All you have to do is open an HTTP endpoint on the same server that's running your Discord bot (preferably in the same process, maybe a different thread), so UptimeRobot knows when your Discord bot comes online and goes offline.

To create the HTTP endpoint, you can use the built in http.server module, or ️ Flask. Note that, in order for UptimeRobot to make a connection with the server hosting the Discord bot, port forwarding needs to be done. If you don't have access to the network, you can use a service like ngrok to publicly expose the port the server is running on.


All services mentioned above are free , and are not affiliate links.

Related