Odoo Help

8 Answers
Vo Minh Thu
2/12/13, 5:24 PM

In 6.1, there is an additional script called openerp-cron-worker to run a process dedicated to cron jobs.

In 7.0, the recommended way is to use the integrated multi-processing support (i.e. not Gunicorn although it should work). The option --workers sets how many HTTP workers are started, while the option --max-cron-threads sets how many cron workers are started. That option is misleading: both HTTP and cron workers, when using --workers, are real processes. If you still want to use Gunicorn, you may want to try --workers 0 and --max-cron-threads 1 to have a dedicated cron process.

Your question is tagged as 7.0 but refers to the oe script which has been recently added in trunk. If its features are too limited (which seems the case with what you say) or bugged, please create a bug report on launchpad. Otherwise this should be the right way to start cron workers in the future (independently of the integrated multi-process support with the --workers option).

1 Comment
5/3/13, 4:57 AM

Is it possible when defining conf['workers'] = '0' and conf['max_cron_threads'] = '1' in gunicorn.conf.py ? . I've tried that but it didnt worked .


Vasiliy Birukov

--Vasiliy Birukov--
| 7 6 8
Togliatty, Russian Federation
--Vasiliy Birukov--

Help develop and implement any project on base Odoo.

Vasiliy Birukov
12/5/14, 9:07 AM

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


Guewen Baconnier

--Guewen Baconnier--

| 6 7 8
Lausanne, Switzerland
--Guewen Baconnier--

Guewen works at Camptocamp as an Odoo developer since 2010. He is the lead developer of the Odoo Connector framework and the Magento Connector. He is a delegate member of the OCA, a committer and an active contributor to the OCA projects.


Guewen Baconnier
2/12/13, 10:19 AM

Since version 7.0, the cron workers are launched automatically when you start openerp in multi-process mode.

It spawn n HTTP workers where n is a number in the configuration key workers, and it spawn m Cron workers where m is a number in the configuration key max_cron_threads.

Viktor Nagy
10/11/14, 10:43 AM

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


NB: finally my solution is to drop gunicorn from the stack, and use the openerp-server command with workers and max-cron-threads set as suggested above

Eugen Don
2/23/17, 4:14 PM

Hi my Friend, there is an app to start cron workers manually espacially for cases where users run their instances in wsgy mode.

You can also assign a automated action to the function of this module.


Best Regards Eugen


Andreas Brueckl

--Andreas Brueckl--

| 7 8 7
Vienna, Austria
--Andreas Brueckl--
OpenERP Consulting and Development
Andreas Brueckl
2/12/13, 10:39 AM

Thank you for the answer.

I run gunicorn with the following command: "gunicorn openerp:wsgi.wsgi_server.application -c ../gunicorn.conf.py"

Here is my guniconf.conf.py file:

import openerp 
import multiprocessing 
bind = '' 
pidfile = '.gunicorn.pid'   
conf = openerp.tools.config

conf['addons_path'] =  "openerp/addons,../addons,../web/addons,../custom-addons"
conf['db_host'] = False 
conf['db_port'] = 5433 
conf['db_user'] = 'user1' 
conf['db_password'] = 'xx' 
conf['dbfilter'] = 'test.*'

conf['logfile'] = '/var/log/openerp-server-7.log'

workers = multiprocessing.cpu_count() * 2 + 1

When I look into the source in method "application" of wsgi_server.py I cannot see where the cron jobs will be started. There are only 2 files which handle "max_cron_threads": "server/openerp/service/workers.py" and "server/openerp/service/cron.py". Both of them are not called in gunicorn-mode.

Maybe I misunderstand something. How to I correctly run openerp in multiprocess-mode?

1 Comment
Daniel Reis
2/12/13, 11:01 AM

Andreas, to add more details to your question you should edit it expanding the additional details, instead of posting them as an "answer".

Ask a Question
Keep Informed
2 follower(s)
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now