我试图安装并启动一个简单的CherryPy服务器作为Windows服务。安装并启动CherryPy服务器脚本作为Windows服务(使用sc.exe)
下面是脚本:(去掉了一些线剪短通过命令行手动执行时,它的完全工作)
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()
我使用sc.exe
安装和启动服务。安装顺利,但我似乎无法启动服务。
使用的命令是:(注意有是在路径空间,虽然我HANDELING这个用双引号,和binPath
通过命令行手动执行其字符串时,工作)
> sc.exe create "ServiceName" binPath= "\"C:\Path to Python\python.exe\" \"C:\Path to CherryPy Script\cherryserver.py\""
> sc.exe start "ServiceName"
我不断收到此错误,不管试图开始使用sc.exe
或通过services.msc
GUI服务:
[SC] StartService FAILED 1053:
The service did not respond to the start or control request in a timely fashion.
据我了解,这是因为happenning python.exe
不IMPL提供Windows服务API。
我不想从脚本创建.exe
,使用py2exe。
我发现this answer该建议安装使用不同的工具的服务比sc.exe
,称为srvany.exe
& instsrv.exe
。但是,我无法在Win2K Resource Kit website中找到它们。
是否有人知道如何安装&作为Windows成功启动此.py
?
有谁知道
谢谢,但我一直在寻找这样做的最快的途径,而无需做任何改变我自己。 – 2011-05-19 23:31:49