Using forever.js with Python

前端 未结 3 1272
花落未央
花落未央 2021-01-31 10:43

Two questions:

  • Is there a Python equivalent to forever.js to run a Python process in the background without requiring sudo?
  • Is it possible to use forever.
3条回答
  •  耶瑟儿~
    2021-01-31 11:30

    It is easy to use Python with forever.js:

    forever start -c python python_script.py
    

    To use it with virtualenv is a little bit more complicated, I did it using a bash script (call it python_virtualenv):

    #!/bin/bash
    # Script to run a Python file using the local virtualenv
    source bin/activate
    bin/python $@
    

    Now use that script with forever:

    forever start -c ./python_virtualenv python_script.py
    

提交回复
热议问题