Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/313.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 作为Linux系统服务从virtualenv中启动wsgi应用程序_Python_Linux_Wsgi_Bottle - Fatal编程技术网

Python 作为Linux系统服务从virtualenv中启动wsgi应用程序

Python 作为Linux系统服务从virtualenv中启动wsgi应用程序,python,linux,wsgi,bottle,Python,Linux,Wsgi,Bottle,我目前正在virtualenv中开发一个瓶子应用程序。我打算使用bjoern WSGI服务器为其提供服务(但这可能并不重要)。我还打算使用lighty或nginx反向代理为应用程序提供服务。无论如何,这个应用程序可以作为一个系统服务在自己的virtualenv中运行吗?如果是这样的话,你会怎么做呢?根据我的经验,我建议你可以使用来运行你的web服务器作为守护进程服务。虽然您可以在/etc/init.d中编写一些Linux服务脚本,但它们确实很难正确执行。下面是一个在Ubuntu中将其作为服务运行

我目前正在virtualenv中开发一个瓶子应用程序。我打算使用bjoern WSGI服务器为其提供服务(但这可能并不重要)。我还打算使用lighty或nginx反向代理为应用程序提供服务。无论如何,这个应用程序可以作为一个系统服务在自己的virtualenv中运行吗?如果是这样的话,你会怎么做呢?

根据我的经验,我建议你可以使用来运行你的web服务器作为守护进程服务。虽然您可以在/etc/init.d中编写一些Linux服务脚本,但它们确实很难正确执行。下面是一个在Ubuntu中将其作为服务运行的示例。你不想写一个,是吗

要使用supervisord运行依赖于virtualenv作为守护进程服务的python服务器,下面是我在生产环境中使用的配置

[program:web01]
command=/home/victorlin/tg2env/bin/paster serve production.ini ;
process_name=%(program_name)s ;
directory=/home/victorlin/ ;
user=victorlin ;
priority=999 ;
redirect_stderr=true ;
stdout_logfile=/home/victorlin/logs/web01_out.txt ;
stderr_logfile=/home/victorlin/logs/web01_err.txt ;
environment=PYTHON_EGG_CACHE=/home/victorlin/.python-eggs ;
您可以使用/path/to/virtualenv/bin/python在命令字段中运行自己的python脚本。而且,要在启动时运行supervisord,您可以在根帐户中编写如下crontab:

@reboot /usr/local/bin/supervisord -c /home/root/supervisord.conf 

当然,如果您没有小于1024的端口号可打开,您可以将此启动crontab写入非特权帐户。

Rats!无法通过“轻松安装”安装管理器。。。他们自己网站上列出的下载路径似乎已过时。无法在系统上安装。我不知道为什么。无论如何,我已经通过编写自己的init脚本解决了这个问题。我会记住您的建议,以防supervisord决定将来安装。:)