使用supervisor / systemctl & nginx &uwsgi 运行odoo

参考

1、

https://acespritechblog.com/2013/04/18/configure-openerp-with-nginx-and-gunicorn/

2、

 https://www.jianshu.com/p/c4790842bd0e

 https://suadminwen.github.io/2017/05/29/nginx+uwsgi%E9%83%A8%E7%BD%B2odoo%E6%9C%8D%E5%8A%A1/

 http://www.fsmgsports.com/post/odoo11-install-and-deploy/

 

---

uwsgi运行odoo的方法:

odoo目录为 /server/odoo/odoo_12c/

1、将odoo目录 setup下odoo-wsgi.py 复制到odoo源码目录(其他目录应该也可以)并配置(类似普通启动odoo时的配置文件)

内容为 :

conf['各种配置名'] = '配置参数'

例如:

# Path to the OpenERP Addons repository (comma-separated for
# multiple locations)
conf['addons_path'] = '/server/odoo/odoo_12c/addons,/server/odoo/odoo_12c/odoo/addons'
# Optional database config if not using local socket
conf['db_name'] = ''
conf['db_host'] = 'localhost'
conf['db_user'] = 'odoo'

2、建立odoo-wsgi.py的配置文件odoo-wsgi.ini

[uwsgi]
# http 测试时使用 socket 通过nginx代理时 使用的端口
http = :9991
#socket = :9991
uid = s2
# 项目地址
chdir = /server/odoo/odoo_12c/
#
wsgi-file = odoo-wsgi.py
processes = 4
threads = 2
buffer-size = 50000
stats = 127.0.0.1:9191
logto2= /server/log/odoo/odoo_12c/uwsgi_odoo12.log
#pythonpath = /server/pyvenv/odoo12c/bin/python3.7
plugins=python3

 

3. 虚拟环境下安装uwsgi

进入虚拟环境

source /server/pyvenv/odoo12c/bin/activate

pip3 install uwsgi

4.运行

/server/pyvenv/odoo12c/bin/uwsgi /server/odoo/odoo_12c/odoo-wsgi.ini

 

可以试一下http://localhost:9991

 5.配置nginx

server {
    listen       82;
    server_name  0.0.0.0;
        #log files
        access_log /var/log/nginx/odoo11c/odoo11c_access.log;
        error_log /var/log/ngonx/odoo11c/odoo_error.log;

     location / {
        include        uwsgi_params;
        uwsgi_pass     127.0.0.1:9912;
     }

     location /longpolling/ {
        proxy_pass        http://localhost:8072/longpolling/;
        proxy_redirect    off;
        proxy_set_header  X-Real-IP        $remote_addr;
        proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
     }



#ssl files

#    ssl                  on;
#    ssl_certificate      cert.pem;
#    ssl_certificate_key  cert.key;

#    ssl_session_timeout  5m;

#    ssl_protocols  SSLv2 SSLv3 TLSv1;
#    ssl_ciphers  HIGH:!aNULL:!MD5;
#    ssl_prefer_server_ciphers   on;


# proxy pass # location / { # proxy_pass http://localhost:8011; # proxy_redirect off; # proxy_set_header Host $host; # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # proxy_set_header X-Real-IP $remote_addr; # }
}

 其他:

systemctl 或 supervisor 用于自启动

supervisor

[program:odoo12c]

# python odoo #command=/server/pyvenv/odoo12c/bin/python3.7 /server/odoo/odoo_12c/odoo-bin -c /server/odoo_conf/odoo12c.conf
#wsgi-odoo
command=/server/pyvenv/odoo12c/bin/uwsgi /server/odoo/odoo_12c/odoo-wsgi.ini
#自动启动
autostart=true autorestart=true startsecs=8

#enviroment environment=HOME="/server/odoo",USER="odoo" #environment=PYTHONPATH="$PYTHONPATH:/server/odoo/odoo_11c/venv/bin" user=odoo redirect_stderr=true stdout_logfile=/var/log/supervisord/odoo12c/supervisor-odoo12c.log stdout_logfile_maxbytes=500MB stdout_logfile_backups=50 stdout_capture_maxbytes=1MB stdout_events_enabled=false loglevel=warn

centos systemctl

vi /etc/systemd/system/uwsgi-odoo12c.service

[Unit]
Description=uwsgi-odoo12c
Requires=postgresql-12.service
After=network.target postgresql-12.service

[Service]
Type=simple
SyslogIdentifier=odoo12c
PermissionsStartOnly=true
User=odoo
Group=odoo
WorkingDirectory=/home/odoo
Environment=/data/odoo/pyvenv/odoo12/bin/activate
ExecStart=/server/pyvenv/odoo12c/bin/uwsgi /server/odoo/odoo_12c/uwsgi/odoo12c-wsgi.ini
#ExecStart=/server/pyvenv/odoo12c/bin/python3.7 /server/odoo/odoo_12c/odoo-bin -c /server/odoo_conf/odoo12c.conf
# ExecStart=/usr/bin/scl enable rh-python36 -- /opt/odoo/odoo12-venv/bin/python3 /opt/odoo/odoo12/odoo-bin -c /etc/odoo12.conf StandardOutput=journal+console [Install] WantedBy=multi-user.target

 

转载于:https://www.cnblogs.com/misstaste/p/9821032.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值