Is there Windows analog to supervisord?

前端 未结 6 1608
情书的邮戳
情书的邮戳 2020-12-01 01:08

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 sc

6条回答
  •  孤城傲影
    2020-12-01 01:49

    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.

    Here's my recipe:

    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
      
    4. 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).

    5. 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"
      
    6. Go to the Windows service manager and start the service supervisord that you just installed.

    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.

提交回复
热议问题