Linux 下使用supervisor管理源码启动的openerp
-
从源码启动openerp,简单的做法是添加启动脚本到/etc/init.d/rc.local等,让openerp 随系统启动而运行。此类方法只在系统启动时运行,但万一程序在运行中崩溃,您可能要等到用户发现不能使用了,才去重启服务器。下面请出今天的主角: supervisor (http://supervisord.org/)
Supervisor 是什么?
Supervisor is a client/server system that allows its users to monitor and control a number of processes on UNIX-like operating systems.
Supervisor 是一个客户端/服务器系统,允许用户监控和控制类 Unix 操作系统上的进程数。
1、安装
debian/ubuntu<br />apt-get install supervisor<br />
redhat/centos<br />yum install supervisor<br />
2、建立openerp 的配置文件<br /># touch /etc/supervisor/conf.d/openerp.conf<br /># vi /etc/supervisor/conf.d/openerp.conf<br />
openerp.conf 内容<br />[program:openerp]<br />; openerp 启动脚本<br />command=python /var/www/openerp-6.1-1/openerp-server -c /var/www/openerp-6.1-1/openerp-server.conf<br />; openerp 目录<br />directory=/var/www/openerp-6.1-1/<br />; 是否随系统启动<br />autostart=true<br />; 自动重启<br />autorestart=true<br />; 启动时间,如果超过这个时间oe还没有挂,则视为已经启动<br />startsecs=3<br />; 启动用户<br />user=www-data<br />redirect_stderr=true<br />; log 文件<br />stdout_logfile=/var/www/openerp-6.1-1/openerp-server.log<br />stdout_logfile_maxbytes=500MB<br />stdout_logfile_backups=50<br />stdout_capture_maxbytes=1MB<br />stdout_events_enabled=false<br />loglevel=warn<br />
3、完成!重启系统试试看openerp 是否已经启动。也可以想办法把openerp 搞崩溃,试试supervisor 能不能及时将openerp 重启
4、常用命令<br /># supervisorctl<br />openerp RUNNING pid 9454, uptime 4:43:34<br />supervisor> start openerp #启动<br />supervisor> stop openerp #停止<br /> supervisor> restart openerp #重启<br /> supervisor> status openerp #查看状态<br />
-
感谢 wangbuke,
supervisor确实是好东西,我们公司之前的trac项目管理平台就是用supervisor部署的。感觉非常灵活好用。
另外技术八卦一下,supervisor的开发团队和pyramid框架的团队是一波人,属于牛人作品,不错。 -
按照楼主的教程,尝试着用supervisor来启动odoo,status总显示这个错误:
FATAL Exited too quickly (process log may have details)
这个要怎么搞呢,是不是odoo的配置还要做什么更改,求正确的方法
odoo8 BACKOFF Exited too quickly (process log may have details)
supervisor> status
odoo8 STARTING
supervisor> status
odoo8 FATAL Exited too quickly (process log may have details)
-------------------------------------------
我的odoo8的目录在cd /sdyun/odoo/server/odoo8
odoo用户下用这个命令启动时没有问题的:$ python /sdyun/odoo/server/odoo8/openerp-server -c odoo8.conf
supervisord中关于odoo的配置<br />command=/usr/local/bin/python /sdyun/odoo/server/odoo8/openerp-server -c /sdyun/<br />odoo/server/odoo8/odoo8.conf<br />; openerp 目录<br />directory=/sdyun/odoo/server/odoo8/<br />
与楼主不同的是直接python 提示找不到 python 我加了/usr/local/bin/python 其他的一样
---------------------------------------log----------------------------------------------Traceback (most recent call last):<br /> File "/sdyun/odoo/server/odoo8/openerp-server", line 5, in <module><br /> openerp.cli.main()<br /> File "/sdyun/odoo/server/odoo8/openerp/cli/__init__.py", line 68, in main<br /> o.run(args)<br /> File "/sdyun/odoo/server/odoo8/openerp/cli/server.py", line 180, in run<br /> main(args)<br /> File "/sdyun/odoo/server/odoo8/openerp/cli/server.py", line 140, in main<br /> openerp.tools.config.parse_config(args)<br /> File "/sdyun/odoo/server/odoo8/openerp/tools/config.py", line 360, in parse_co<br />nfig<br /> openerp.modules.module.initialize_sys_path()<br /> File "/sdyun/odoo/server/odoo8/openerp/modules/module.py", line 96, in initial<br />ize_sys_path<br /> dd = tools.config.addons_data_dir<br /> File "/sdyun/odoo/server/odoo8/openerp/tools/config.py", line 685, in addons_d<br />ata_dir<br /> os.makedirs(d, 0700)<br /> File "/usr/local/lib/python2.7/os.py", line 150, in makedirs<br /> makedirs(head, mode)<br /> File "/usr/local/lib/python2.7/os.py", line 150, in makedirs<br /> makedirs(head, mode)<br />:<br />OSError: [Errno 13] Permission denied: '/.local'Traceback (most recent call last):<br /> File "/sdyun/odoo/server/odoo8/openerp-server", line 5, in <module><br /> openerp.cli.main()<br /> File "/sdyun/odoo/server/odoo8/openerp/cli/__init__.py", line 68, in main<br /> o.run(args)<br /> File "/sdyun/odoo/server/odoo8/openerp/cli/server.py", line 180, in run<br /> main(args)<br /> File "/sdyun/odoo/server/odoo8/openerp/cli/server.py", line 140, in main<br /> openerp.tools.config.parse_config(args)<br /> File "/sdyun/odoo/server/odoo8/openerp/tools/config.py", line 360, in parse_config<br /> openerp.modules.module.initialize_sys_path()<br /> File "/sdyun/odoo/server/odoo8/openerp/modules/module.py", line 96, in initialize_sys_path<br /> dd = tools.config.addons_data_dir<br /> File "/sdyun/odoo/server/odoo8/openerp/tools/config.py", line 685, in addons_data_dir<br /> os.makedirs(d, 0700)<br /> File "/usr/local/lib/python2.7/os.py", line 150, in makedirs<br /> makedirs(head, mode)<br /> File "/usr/local/lib/python2.7/os.py", line 150, in makedirs
------------------log--------------------
------------------------------
用楼下的办法成功解决<br />environment=HOME="/home/YourName",USER="YourName"<br />
然后
配置文件中user的那一行不能漏掉
我这里的环境配置是:<br />[program:odoo8]<br />; openerp 启动脚本<br />command=/usr/local/bin/python /sdyun/odoo/server/odoo8/openerp-server -c /sdyun/<br />odoo/server/odoo8/odoo8.conf<br />; openerp 目录<br />directory=/sdyun/odoo/server/odoo8/<br />; 是否随系统启动<br />autostart=true<br />; 自动重启<br />autorestart=true<br />; 启动时间,如果超过这个时间oe还没有挂,则视为已经启动<br />startsecs=30<br />; 启动用户<br />environment=HOME="/sdyun/odoo",USER="odoo"<br />user=odoo<br />redirect_stderr=true<br />; log 文件<br />stdout_logfile=/var/log/supervisord/odoo/odoo8/openerp-server.log<br />stdout_logfile_maxbytes=500MB<br />stdout_logfile_backups=50<br />stdout_capture_maxbytes=1MB<br />stdout_events_enabled=false<br />loglevel=warn<br />
-
[quote author=mom988 link=topic=4250.msg31934#msg31934 date=1456370417]
FATAL Exited too quickly (process log may have details)
这个要怎么搞呢,是不是odoo的配置还要做什么更改
odoo8 BACKOFF Exited too quickly (process log may have details)
supervisor> status
odoo8 STARTING
supervisor> status
odoo8 FATAL Exited too quickly (process log may have details)
[/quote]
启动没成功。
你这样问问题,想要别人怎么帮你。而且问问题最好开一个新帖。 -
@mom988 这样提问题就对了嘛 ;D
从你的错误log里看,这句是关键:<br />OSError: [Errno 13] Permission denied: '/.local'Traceback (most recent call last):<br />
Odoo在启动过程中需要检查一个data目录,其中用来保存Odoo用户的附件文档,Session数据,以及通过网络安装的模块。
它一般保存在启动Odoo的用户的HOME目录的.local目录下
当用supervisor来启动Odoo时,因为supervisorsd是由root用户启动的,所以它只继承了root的环境变量。这样当启动Odoo的时候,Odoo就会试图在/.local下创建data目录时就会遭遇‘Permission Denied' 权限错误,因为Odoo并不是root的启动的,该用户是没有在/上创建目录权限。
解决的办法是,在supervisor配置文件中设置环境变量,比如:
[font=Consolas][/font]environment=HOME="/home/YourName",USER="YourName"
[font=Consolas][/font]