简体   繁体   中英

python waitress as a windows service

I wrote an API server using waitress and falcon on windows. It's working great but now I need to run it as service so it monitorable. What's the best way to do this? I've looked at pywin32 and cherrypy's own implementation . I get stumped on on stopping waitress via python. I know ctrl-break is used when using the cmd but not sure what to use when using python.

def SvcStop(self):
    self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
    cherrypy.server.stop()
    win32event.SetEvent(self.stop_event)

I don't see waitress having a stop function like cherrypy.

Any help would be great. Even if it is outside of pywin32. Just need some details on how get waitress running as a service on windows as there are lots of ways to do it and I'm unsure which is recommended.

Thanks, Anthony

I do not know how to stop Waitress other than just killing the thread. Did you try if it reacts do some signals?

Apart of pywin32 you can also try to use Non-sucking service manager NSSM

I know this question is kind of old, but I have just posted and answer to my own question here , which may also answer this question.

In short, the answer is to use pywin32 plus a sub-thread.
It was the stopping that gave me trouble also, and the answer I have found seems to work cleanly, but I am very interested in feedback on any possible complications to this way of doing it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM