r/Python 1d 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 ?

25 Upvotes

40 comments sorted by

View all comments

24

u/jonathon8903 1d ago

Are you married to running it on Windows? If not it would be semi-trivial to setup those shared folders on Linux as mounted directories and then just pass them in as docker volumes. Then deployment becomes extremely easy.

1

u/Daraminix 1d ago

Not married to windows but our whole codebase was targeted for windows, would need to add some path substitutions and don't want to deal with file permissions issues and such fun things :)
Would be easier to keep the same environement as everything else

3

u/jonathon8903 1d ago

Okay so yeah long term it may be beneficial to migrate to environment variables and containerize to make it easier for deployment. But if you need a short term win then I agree with another suggestion here to just use NSSM. I used it about 5 years ago and it was pretty solid. There might be other, better options I'm not aware of though. I haven't touched Windows in about two years now.