Using forever.js with Python

∥☆過路亽.° 提交于 2020-01-11 15:52:05

问题


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.js with Python? How about with a virtualenv?

回答1:


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



回答2:


I was having problems executing a python script with custom logging paths, after trying I got to work with the next command:

 forever start -c python -l /tmp/forever.log -o /tmp/out.log -e /tmp/error.log python_script.py

Tell me if it worked for you




回答3:


Using python 3 with Flask to run with forever.js, here is my build process

python3 -m venv venv
source venv/bin/activate
sudo -H pip3 install -r requirements.txt
FLASK_APP=app.py forever start -c python3 app.py --port=5001


来源:https://stackoverflow.com/questions/19571282/using-forever-js-with-python

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!