Ory*_*and 0 python windows-services mod-wsgi wsgi cherrypy
我正在尝试安装并启动一个简单的CherryPy服务器作为Windows服务.
这是脚本:(删除了一些行来缩短它.当从命令行手动执行时它完全正常工作)
app = AdminMediaHandler(django.core.handlers.wsgi.WSGIHandler())
logged_app = TransLogger(app)
server = wsgiserver.CherryPyWSGIServer( ('127.0.0.1', 8632), logged_app, server_name='localhost', numthreads=20 )
try:
server.start()
except KeyboardInterrupt:
server.stop()
Run Code Online (Sandbox Code Playgroud)
我正在使用sc.exe安装和启动服务.安装顺利,但我似乎无法启动该服务.
使用的命令是:(注意路径中有空格,虽然我用双引号处理它,并且在binPath通过命令行手动执行其字符串时正在工作)
> sc.exe create "ServiceName" binPath= "\"C:\Path to Python\python.exe\" \"C:\Path to CherryPy Script\cherryserver.py\""
> sc.exe start "ServiceName"
Run Code Online (Sandbox Code Playgroud)
无论是尝试使用GUI sc.exe还是通过services.mscGUI 启动服务,我都会收到此错误:
[SC] StartService FAILED 1053:
The service did not respond to the start or control request in a timely fashion.
Run Code Online (Sandbox Code Playgroud)
据我所知,这是因为python.exe没有实现Windows服务API.
我不希望.exe使用py2exe从脚本创建一个.
我发现这个答案建议使用不同的工具来安装服务,而不是sc.exe名为srvany.exe&instsrv.exe.但是,我在Win2K Resource Kit网站上找不到它们.
有人知道如何成功安装和启动.pyWindows吗?
有人知道吗
CherryPy附带一个用于启动Windows服务的模块.有关如何安装和运行它的说明,请参阅此其他SO问题.您可能希望从当前的方法(将Django应用程序直接传递给WSGIServer)切换,然后使用cherrypy.tree.graft.
| 归档时间: |
|
| 查看次数: |
3916 次 |
| 最近记录: |