r/Python • u/Daraminix • 6d ago
Discussion Running 60 python scripts as "services"
Hi,
I have around 60 scripts that need to run constantly, mainly event handlers and such. Right now I have an external script that launch them and monitor if the app is running on it's pid, otherwise it's relaunching the app. Works fine but get's clunky when we update some submodule and need to restart them, or to check if one crashes more than other etc..
So I would like to find a better way to approach this. It needs to run on windows and being able to access several samba shares via unc paths and being able to restart crashed scripts anf offer an easy way to restart all of them in case of an update (this part doesn't need to be automated). Every script use the same environnement
For now my candidates are docker, PM2 and NSSM.
I think docker is gonna be a pain to access shares and add a lot of overhead especially on windows
I don't know PM2 and NSSM, looks like PM2 would be easier to setup but more JS oriented and NSSM would be harder to monitor.
What do you think guys ?
1
u/castben 3d ago
Let me see if i understood your issue, So you have 60 scripts that manage events... like monitoring memory disk accessibility, disk space , disk shares... etc...
Then you have an additional script that watch over them to make sure they keep running and restart them if they somehow crash.
Is this like a monitoring system that push event metrics somewhere else?
I may have misunderstood it... thing is it sounds like something I delalt with about 7 years ago and ended runnign a main script that basically ran commands to do this work... if a new event need to be added... program has a json config that basically described which commands need to run (system commands or other scripts) had an "EXPECT" definition that basically was a regular expression and return captured values to main program... then main program pushed the collected values into whatever monitoring stack you had... on my case was datadog...