Help

6

OE8 + WSGI : CRON Not working

Avatar
swapnil wagh

Issue: https://github.com/odoo/odoo/issues/3091

I am struggling to make cron/scheduler working in Openerp/ Odoo 8 with mod_wsgi
First I had problem with Odoo css and js were not loading with apache 2.4 and Ubuntu 14.04
http://goo.gl/LLBCAg Later I started working on Ubuntu 12.04 with apahce 2.2 it work for me, still my question on forum is open if any one face same issue and has solution please share.

Now I am struggling with other problem, and its problem from v7 , here is my conf

<VirtualHost *:80>
        ServerName domain.com
        WSGIScriptAlias / /home/swapnil/my_workspace/OpenERP/odoo-workspace/odoo-8.0/openerp-wsgi.py
        WSGIDaemonProcess oe user=openerp group=openerp processes=4 python-path=/home/swapnil/my_workspace/OpenERP/odoo-workspace/odoo-8.0display-name=apache-openerp
        WSGIProcessGroup oe
        <Directory /home/swapnil/my_workspace/OpenERP/odoo-workspace/odoo-8.0 >
                #Options FollowSymLinks
                #AllowOverride All
                Order deny,allow
                Allow from all
        </Directory>
        ErrorLog /home/logs/apache-openerp.log
</VirtualHost>

openerp-wsgi.py conf:

import openerp

#----------------------------------------------------------
# Common
#----------------------------------------------------------
openerp.multi_process = True # Nah!

# Equivalent of --load command-line option
openerp.conf.server_wide_modules = ['web']
conf = openerp.tools.config

# Path to the OpenERP Addons repository (comma-separated for
# multiple locations)

conf['addons_path'] = '/home/swapnil/my_workspace/OpenERP/odoo-workspace/odoo-8.0/openerp/addons,/home/swapnil/my_workspace/OpenERP/odoo-workspace/odoo-8.0/addons'   #path from home folder to openerp

# Optional database config if not using local socket
#conf['db_name'] = 'mycompany'
conf['db_host'] = 'localhost'
conf['db_user'] = 'odoo'
conf['db_port'] = 5432
conf['db_password'] = 'password'

#----------------------------------------------------------
# Generic WSGI handlers application
#----------------------------------------------------------
application = openerp.service.wsgi_server.application

#----------------------------------------------------------
# Gunicorn
#----------------------------------------------------------
# Standard OpenERP XML-RPC port is 8069
bind = '0.0.0.0:8069'
pidfile = '.gunicorn.pid'
workers = 4
timeout = 240
max_requests = 2000

After this everything work fine for me except the crons :(
Any one can help me to solve this issue.

Avatar
Discard
3 Answers
6
Avatar
Vasiliy Birukov
Best Answer

Try our module cron for manual start cron from odoo interface.

Avatar
Discard
2
Avatar
odookillsme
Best Answer

You need to add these lines to your wsgi-file in order to make cron jobs work

from openerp.service.server import ThreadedServer
 

and after the "openerp.service.server.load_server_wide_modules()"


ThreadedServer(None).cron_spawn()

Avatar
Discard
2
Avatar
Viktor Nagy
Best Answer

I just run into this same problem running an instance with uwsgi (not gunicorn). The instance was running fine for more than a month, but no cron jobs were running.
The reason behind this unexpected behavior was pretty simple. The cron jobs are never started running only a simple wsgi application.

I've followed the code base as much as I could, and the only places where cron jobs are started are when openerp is started from the command line. Thus cron is never started for wsgi apps.
For this reason, you have 2 possibilities:

  1. run a separate openerp-server instance that is initialised, and will only consume your cron job
  2. add the cron init code to your wsgi initialisation

I've tried the latter. My current setup seems to work well, but I'm not sure if it's really OK or not. Here follows what I did:

  1. Add an `import cron` line towards the top of openerp/service/wsgi_server.py.
  2. Add `cron.start_service()` around line 413, after the `openerp.service.start_internal()` call.
  3. Restart your server
4 Comments
Avatar
Discard
Avatar
swapnil wagh
-

@Viktor Thanks for comment will try it for sure

Avatar
swapnil wagh
-

@Viktor sorry I forgot to mention the version I am looking for odoo 8 your solution work at least for me in v7. You have any idea for v8 as the code is completely different

Avatar
Viktor Nagy
-
nope

On Tue, Oct 14, 2014 at 5:45 PM, swapnil wagh <wagh-aswapnil-gmail-com@mail.odoo.com> wrote:

@Viktor sorry I forgot to mention the version I am looking for odoo 8 your solution work at least for me in v7. You have any idea for v8 as the code is completely different

--
swapnil wagh
Sent by OpenERP S.A. using Odoo about Forum Post False

Avatar
swapnil wagh
-
Please let me know if you git the solution, thanks in advance

On Wed, Oct 15, 2014 at 10:51 AM, Nagy Viktor <viktor.nagy@toolpart.hu> wrote:
nope

On Tue, Oct 14, 2014 at 5:45 PM, swapnil wagh <wagh-aswapnil-gmail-com@mail.odoo.com> wrote:

@Viktor sorry I forgot to mention the version I am looking for odoo 8 your solution work at least for me in v7. You have any idea for v8 as the code is completely different

--
swapnil wagh
Sent by OpenERP S.A. using Odoo about Forum Post False

--
Viktor Nagy
Sent by OpenERP S.A. using Odoo about Forum Post False