Search code examples
pythonserverpycharm

Run python script as a service on Windows with an interface


I have a problem where I think that I already have a solution. The only thing I need to know is a bit of knowledge and a rough direction how to do it.

My problem: A script is running via PyCharm on a server. When the server is rebooting, because of updates or something similar, I need to restart PyCharm and start the script. I don't get any information that the process has stopped. Moreover without logon via remote desktop and starting PyCharm, the script would not be up again.

Solution: Start the script as a service and write another script that checks if the process is running.

trains of thought My problem is, that by running the script as a service I will loose my IDE (my interface that I have with PyCharm). The way I interact with the script is then moved to my two logging files. How will I know if the script is still running? What will happen if an error occurs, that is not handled by my logging setup. What if an exception raises? Will it be printed to the logfile?

It's hard for me to disengage from an interface and do everything in a console. I am then dependent on the log files. That's pretty new to me.

I think that if I start the script as a service, that it becomes a blackbox.

Notes: I read this guide here, how I can set up a windows service and I set up my logging. How can I run my script as a service without loosing information?


Solution

  • I guess that I already had my answer, when I asked this question. So without writing a server/client interface, I have to live with my log-files. Acknowledgements for the guidance in the comments.