Python脚本位置:
~/src/myproject/python/bin/myproject.py
我去了目录:
~/src/myproject/python
并跑了:
workon myproject-dev
然后我运行以下命令。一切都很好。
(myproject-dev)myadmin@myhost:~/src/myproject/python$ which python
/home/myadmin/.virtualenvs/myproject-dev/bin/python
(myproject-dev)myadmin@myhost:~/src/myproject/python$ python ~/src/myproject/python/bin/myproject.py -c ~/src/temp/myproject.conf
我计划使用upstart脚本来完成上述工作,但失败了。我搜索了问题,例如https://gist.github.com/swinton/1978897。但还是不知道。以下是upstart脚本。欢迎提出任何建议。
env PYTHON_HOME=/home/myadmin/.virtualenvs/myproject-dev
start on runlevel [2345]
stop on runlevel [!2345]
script
cd ~/src/myproject/python
workon myproject-dev#activate the virtualenv
add2virtualenv /home/myadmin/src/myproject/python#Add myproject source to path
exec $PYTHON_HOME/bin/python ~/src/myproject/python/bin/myproject.py -c ~/src/temp/myproject.conf
end script
更新
运行" sudo service test-env start"后,输出为
start/running, process 12361
然后运行" sudo service test-env status",输出
test-env stop/waiting
服务无法启动...