rdavydov / Twitch-Channel-Points-Miner-v2

A simple script that will watch a stream for you and earn the channel points.
GNU General Public License v3.0
1.1k stars 326 forks source link

feat: add health check command to the container #516

Closed pyrooka closed 1 week ago

pyrooka commented 2 months ago

Description

This PR adds a small improvement to the container, which utilises the Docker HEALTHCHECK command to report the inner state of the app to the Docker runtime. Basically, it runs the curl command periodically to check whether the webserver is up or not.

Motivation: I left a typo in my run.py file that I didn't notice and restarted the host around an hour later. That small issue led to a restart loop, but my Portainer instance reported Running - which in fact was true. I think if it would've had this health check, I could see the problem on the UI.

Type of change

How Has This Been Tested?

I started a local container with the example run.py and when I inspected it, I could see the error logs:

{
    "Start": "2024-04-30T21:54:22.04317247Z",
    "End": "2024-04-30T21:54:22.126576887Z",
    "ExitCode": 1,
    "Output": "  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current\n                                 Dload  Upload   Total   Spent    Left  Speed\n\r  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0\r  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0\ncurl: (7) Failed to connect to localhost port 5000 after 1 ms: Couldn't connect to server\n"
}

Running the same health check command in my "prod" container, returned exit code 0 which means everything is fine.

Checklist:

rdavydov commented 2 weeks ago

@pyrooka what if the user doesn't want to run Analytics?

pyrooka commented 1 week ago

Ahh, you're right I missed that part. I've thought about this a little and I'm gonna close this PR, because there is no other "easy" and reliable solution I can think of. As a workaround I'll configure Uptime Kuma to watch the analyitics server, that should be good enough. Thanks for taking a look though!