参考:

http://blog.sina.com.cn/s/blog_7cb52fa80102vrri.html

odoo 在配置workers后会有如下错误

Traceback (most recent call last):

  File "/opt/odoo/openerp/http.py", line 530, in _handle_exception

    return super(JsonRequest, self)._handle_exception(exception)

  File "/opt/odoo/openerp/http.py", line 567, in dispatch

    result = self._call_function(**self.params)

  File "/opt/odoo/openerp/http.py", line 303, in _call_function

    return checked_call(self.db, *args, **kwargs)

  File "/opt/odoo/openerp/service/model.py", line 113, in wrapper

    return f(dbname, *args, **kwargs)

  File "/opt/odoo/openerp/http.py", line 300, in checked_call

    return self.endpoint(*a, **kw)

  File "/opt/odoo/openerp/http.py", line 796, in __call__

    return self.method(*args, **kw)

  File "/opt/odoo/openerp/http.py", line 396, in response_wrap

    response = f(*args, **kw)

  File "/opt/odoo/addons/bus/bus.py", line 188, in poll

    raise Exception("bus.Bus unavailable")

原因:

工人> 0会有很多线程在端口8069上。

你也会有几个cron线程8069(max-cron-threads)。

一个gevent线程在端口8072上(longpolling-port)。

这里的问题就在8072上,web会用8069请求longpolling。所以http出错。

解决办法:

通过设置反向代理的方式来解决

反向代理设置参考:https://www.myfreax.com/add-nginx-reverse-proxy-for-odoo/

1、安装nginx作为反向代理,需要配置nginx的conf文件,其文件内容加入:

upstream odoo {
 server 127.0.0.1:8069;
}

upstream odoo-chat {
 server 127.0.0.1:8072;
}

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

   proxy_read_timeout 720s;
   proxy_connect_timeout 720s;
   proxy_send_timeout 720s;
   proxy_set_header X-Forwarded-Host $host;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
   proxy_set_header X-Forwarded-Proto $scheme;
   proxy_set_header X-Real-IP $remote_addr;


location / {
        proxy_pass        http://odoo;
        proxy_redirect    off;
}

location /longpolling/ {
        proxy_pass        http://odoo-chat;
        proxy_redirect    off;
}


 location ~* /web/static/ {
       proxy_cache_valid 200 90m;
       proxy_buffering    on;
       expires 864000;
       proxy_pass http://odoo;
  }

2、修改odoo.conf文件,设置为代理,

workers = 3
proxy_mode = True

#如果需要禁止外部机器访问8069端口,需要加入下面的配置
xmlrpc_interface = 127.0.0.1
netrpc_interface = 127.0.0.1

至此,重启nginx和odoo服务后,问题将可以得到解决.

12-26 11:25