python - 如何将 python 3.6.4 中构建的烧瓶框架脚本作为 Windows 服务运行
问题描述
我目前正在尝试使用 Flask 框架编写的 python 脚本来实现并作为 Windows 服务运行。
尝试使用不同的解决方案,如下链接: http: //www.chrisumbel.com/article/windows_services_in_python
但得到相同的Windows错误:
D:\>python PySvc.py start
Starting service PySvc
Error starting service: The service did not respond to the start or control
request in a timely fashion.
请帮助我,因为我无法继续进行此操作。
解决方案
根据您的要求,我认为您应该看看NSSM,它是在 Windows 上将 python 脚本作为服务运行的好工具。
您可以像这样设置 NSSM:
nssm.exe install MyPythonScriptService
然后,会弹出一个对话框: 对话框
您需要填写 3 个字段:
Application Path: C:\Python32\python.exe
Startup Directory: C:\Path\To\My\Python\Script\
Arguments: C:\Path\To\My\Python\Script\script.py
然后,点击安装服务。转到 services.msc 并确保您的服务已启动并正在运行。
希望对你有帮助!