4

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?

bad_coder
  • 11,289
  • 20
  • 44
  • 72
Erik Steiner
  • 581
  • 1
  • 5
  • 18
  • Does this answer your question ? [enter link description here](https://stackoverflow.com/questions/4438020/how-to-start-a-python-file-while-windows-starts) – Pawan kumar Jul 09 '18 at 11:25
  • @Pawankumar: The problem is, that it don't make much sense to start PyCharm with windows. If I don't log into the server, it will not trigger the autostart. So in my opinion, it would be the best to start the script as a service. Even if I don't log into the server, the script would be started with the server. – Erik Steiner Jul 09 '18 at 11:29
  • 1
    There's probably a way of doing what you want to do, but I highly encourage you to not be afraid of running your script without PyCharm. Your setup right now is all kinds of weird. I don't know much about Windows, but I'm sure you can find an easy way of logging exceptions, notifying you of errors and whatnot (personally I use telegram-send to notify me about stuff crashing). That's something you'll eventually want learn. So why not start now? – Fred Jul 09 '18 at 13:44

1 Answers1

0

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.

bad_coder
  • 11,289
  • 20
  • 44
  • 72
Erik Steiner
  • 581
  • 1
  • 5
  • 18