本文介绍了是否有 Windows 模拟到 supervisord?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要运行 python 脚本并确保它在终止后会重新启动.我知道有一个名为 supervisord 的 UNIX 解决方案.但不幸的是,我的脚本必须运行的服务器在 Windows 上.你知道什么工具有用吗?谢谢

I need to run python script and be sure that it will restart after it terminates. I know that there is UNIX solution called supervisord. But unfortunately server where my script has to be run is on Windows. Do you know what tool can be useful?Thanks

推荐答案

尽管在这里有很大的免责声明,您可以在 Windows 中使用 Cygwin 运行 Supervisor;事实证明,Cygwin 在模拟 Posix 环境方面走了很长一段路,以至于实际上 supervisord 运行不变.无需学习新工具,如果您需要跨多个平台部署复杂的项目,您甚至可以节省相当多的工作.

Despite the big fat disclaimer here, you can run Supervisor with Cygwin in Windows; it turns out that Cygwin goes a long way to simulate a Posix environment, so well that in fact supervisord runs unchanged. There is no need to learn a new tool, and you will even save quite a bit of work if you need to deploy a complicated project across multiple platforms.

这是我的食谱:

  1. 如果您还没有安装,请安装 Cygwin.在安装过程中,选择 Python.
  2. 从 Cygwin 终端,像往常一样安装 virtualenv.
  3. 为 supervisord 创建一个 virtualenv,然后照常安装:

  1. If you have not done it yet, install Cygwin. During the installation process, select Python.
  2. From the Cygwin terminal, install virtualenv as usual.
  3. Create a virtualenv for supervisord, and then install as usual:

pip install supervisord

  • 以通常的方式配置 supervisord.请记住,supervisord 将与 Cygwin 一起运行,因此您最好使用 Cygwin 方式的路径(C:\myservers\project1 在 Cygwin 中转换为/cygdrive/c/myservers/project1).

  • Configure supervisord in the usual way. Keep in mind that supervisord will be running with Cygwin, so you better use paths the Cygwin way (C:\myservers\project1 translates to /cygdrive/c/myservers/project1 in Cygwin).

    现在您可能希望将 supervisord 安装为服务.我是这样做的:

    Now you probably want to install supervisord as a service. Here's how I do it:

    cygrunsrv --install supervisord --path /home/Administrator/supervisor/venv/bin/python --args "/home/Administrator/supervisor/venv/bin/supervisord -n -c /home/Administrator/supervisor/supervisord.conf"
    

  • 转到 Windows 服务管理器并启动您刚刚安装的服务主管.

  • Go to the Windows service manager and start the service supervisord that you just installed.

    第 5 点将 supervisord 安装为 Windows 服务,以便您可以从 Windows 服务管理器控制它(启动/停止/重新启动).但是你可以用 supervisorctl 做的事情照常工作,这意味着你可以简单地部署你的旧配置文件.

    Point 5 installs supervisord as a Windows service, so that you can control it (start/stop/restart) from the Windows service manager. But the things that you can do with supervisorctl work as usual, meaning that you can simply deploy your old configuration file.

    这篇关于是否有 Windows 模拟到 supervisord?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

  • 06-29 05:30