Skip to content

Commit 7f328d4

Browse files
committed
Merge PR #604 into 17.0
Signed-off-by gurneyalex
2 parents a70fda8 + b9722f9 commit 7f328d4

19 files changed

Lines changed: 1074 additions & 0 deletions
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
========================
2+
Queue Job Cron Jobrunner
3+
========================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:ea15f976f55eddd46d51fc2bb989455756811717bbdc8f69764d02a0d6014b32
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Alpha
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fqueue-lightgray.png?logo=github
20+
:target: https://github.com/OCA/queue/tree/17.0/queue_job_cron_jobrunner
21+
:alt: OCA/queue
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/queue-17-0/queue-17-0-queue_job_cron_jobrunner
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/queue&target_branch=17.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module implements a simple ``queue.job`` runner using ``ir.cron``
32+
triggers.
33+
34+
It's meant to be used on environments where the regular job runner can't
35+
be run, like on Odoo.sh.
36+
37+
Unlike the regular job runner, where jobs are dispatched to the
38+
HttpWorkers, jobs are processed on the CronWorker threads by the job
39+
runner crons. This is a design decision because:
40+
41+
- Odoo.sh puts HttpWorkers to sleep when there's no network activity
42+
- HttpWorkers are meant for traffic. Users shouldn't pay the price of
43+
background tasks.
44+
45+
For now, it only implements the most basic features of the ``queue_job``
46+
runner, notably no channel capacity nor priorities. Please check the
47+
ROADMAP for further details.
48+
49+
.. IMPORTANT::
50+
This is an alpha version, the data model and design can change at any time without warning.
51+
Only for development or testing purpose, do not use in production.
52+
`More details on development status <https://odoo-community.org/page/development-status>`_
53+
54+
**Table of contents**
55+
56+
.. contents::
57+
:local:
58+
59+
Configuration
60+
=============
61+
62+
Warning
63+
64+
Don't use this module if you're already running the regular
65+
``queue_job`` runner.
66+
67+
For the easiest case, no configuration is required besides installing
68+
the module.
69+
70+
To avoid CronWorker CPU timeout from abruptly stopping the job
71+
processing cron, it's recommended to launch Odoo with
72+
``--limit-time-real-cron=0``, to disable the CronWorker timeout
73+
altogether.
74+
75+
Note
76+
77+
In Odoo.sh, this is done by default.
78+
79+
Parallel execution of jobs can be achieved by leveraging multiple
80+
``ir.cron`` records:
81+
82+
- Make sure you have enough CronWorkers available (Odoo CLI
83+
``--max-cron-threads``)
84+
- Duplicate the ``queue_job_cron`` cron record as many times as needed,
85+
until you have as much records as cron workers.
86+
87+
Known issues / Roadmap
88+
======================
89+
90+
- Support channel capacity and priority. (See ``_acquire_one_job``)
91+
- Gracefully handle CronWorker CPU timeouts. (See ``_job_runner``)
92+
- Commit transaction after job state updated to started. (See
93+
``_process``)
94+
95+
Bug Tracker
96+
===========
97+
98+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/queue/issues>`_.
99+
In case of trouble, please check there if your issue has already been reported.
100+
If you spotted it first, help us to smash it by providing a detailed and welcomed
101+
`feedback <https://github.com/OCA/queue/issues/new?body=module:%20queue_job_cron_jobrunner%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
102+
103+
Do not contact contributors directly about support or help with technical issues.
104+
105+
Credits
106+
=======
107+
108+
Authors
109+
-------
110+
111+
* Camptocamp SA
112+
113+
Contributors
114+
------------
115+
116+
- `Camptocamp <https://www.camptocamp.com>`__
117+
118+
- Iván Todorovich <ivan.todorovich@camptocamp.com>
119+
120+
Maintainers
121+
-----------
122+
123+
This module is maintained by the OCA.
124+
125+
.. image:: https://odoo-community.org/logo.png
126+
:alt: Odoo Community Association
127+
:target: https://odoo-community.org
128+
129+
OCA, or the Odoo Community Association, is a nonprofit organization whose
130+
mission is to support the collaborative development of Odoo features and
131+
promote its widespread use.
132+
133+
.. |maintainer-ivantodorovich| image:: https://github.com/ivantodorovich.png?size=40px
134+
:target: https://github.com/ivantodorovich
135+
:alt: ivantodorovich
136+
137+
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
138+
139+
|maintainer-ivantodorovich|
140+
141+
This module is part of the `OCA/queue <https://github.com/OCA/queue/tree/17.0/queue_job_cron_jobrunner>`_ project on GitHub.
142+
143+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "Queue Job Cron Jobrunner",
3+
"summary": "Run jobs without a dedicated JobRunner",
4+
"version": "17.0.1.0.0",
5+
"development_status": "Alpha",
6+
"author": "Camptocamp SA, Odoo Community Association (OCA)",
7+
"maintainers": ["ivantodorovich"],
8+
"website": "https://github.com/OCA/queue",
9+
"license": "AGPL-3",
10+
"category": "Others",
11+
"depends": ["queue_job"],
12+
"data": [
13+
"data/ir_cron.xml",
14+
"views/ir_cron.xml",
15+
],
16+
"installable": True,
17+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<odoo noupdate="1">
3+
4+
<record id="queue_job_cron" model="ir.cron">
5+
<field name="name">Queue Job Runner</field>
6+
<field name="model_id" ref="queue_job.model_queue_job" />
7+
<field name="state">code</field>
8+
<field name="code">model._job_runner()</field>
9+
<field name="queue_job_runner" eval="True" />
10+
<field name="user_id" ref="base.user_root" />
11+
<field name="interval_number">1</field>
12+
<field name="interval_type">days</field>
13+
<field name="numbercall">-1</field>
14+
</record>
15+
16+
</odoo>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * queue_job_cron_jobrunner
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 16.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"Last-Translator: \n"
10+
"Language-Team: \n"
11+
"MIME-Version: 1.0\n"
12+
"Content-Type: text/plain; charset=UTF-8\n"
13+
"Content-Transfer-Encoding: \n"
14+
"Plural-Forms: \n"
15+
16+
#. module: queue_job_cron_jobrunner
17+
#: model:ir.model.fields,help:queue_job_cron_jobrunner.field_ir_cron__queue_job_runner
18+
msgid "If checked, the cron is considered to be a queue.job runner."
19+
msgstr ""
20+
21+
#. module: queue_job_cron_jobrunner
22+
#. odoo-python
23+
#: code:addons/queue_job_cron_jobrunner/models/queue_job.py:0
24+
#, python-format
25+
msgid "Job interrupted and set to Done: nothing to do."
26+
msgstr ""
27+
28+
#. module: queue_job_cron_jobrunner
29+
#: model:ir.model,name:queue_job_cron_jobrunner.model_queue_job
30+
msgid "Queue Job"
31+
msgstr ""
32+
33+
#. module: queue_job_cron_jobrunner
34+
#: model:ir.actions.server,name:queue_job_cron_jobrunner.queue_job_cron_ir_actions_server
35+
#: model:ir.cron,cron_name:queue_job_cron_jobrunner.queue_job_cron
36+
#: model:ir.model.fields,field_description:queue_job_cron_jobrunner.field_ir_cron__queue_job_runner
37+
msgid "Queue Job Runner"
38+
msgstr ""
39+
40+
#. module: queue_job_cron_jobrunner
41+
#: model:ir.model,name:queue_job_cron_jobrunner.model_ir_cron
42+
msgid "Scheduled Actions"
43+
msgstr ""
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * queue_job_cron_jobrunner
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 16.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"PO-Revision-Date: 2022-11-23 09:45+0000\n"
10+
"Last-Translator: Dorin Hongu <dhongu@gmail.com>\n"
11+
"Language-Team: none\n"
12+
"Language: ro\n"
13+
"MIME-Version: 1.0\n"
14+
"Content-Type: text/plain; charset=UTF-8\n"
15+
"Content-Transfer-Encoding: \n"
16+
"Plural-Forms: nplurals=3; plural=n==1 ? 0 : (n==0 || (n%100 > 0 && n%100 < "
17+
"20)) ? 1 : 2;\n"
18+
"X-Generator: Weblate 4.14.1\n"
19+
20+
#. module: queue_job_cron_jobrunner
21+
#: model:ir.model.fields,help:queue_job_cron_jobrunner.field_ir_cron__queue_job_runner
22+
msgid "If checked, the cron is considered to be a queue.job runner."
23+
msgstr "Dacă este bifat, cron-ul este considerat a fi un runner queue.job."
24+
25+
#. module: queue_job_cron_jobrunner
26+
#. odoo-python
27+
#: code:addons/queue_job_cron_jobrunner/models/queue_job.py:0
28+
#, python-format
29+
msgid "Job interrupted and set to Done: nothing to do."
30+
msgstr "Job întrerupt și setat la Terminat: nimic de făcut."
31+
32+
#. module: queue_job_cron_jobrunner
33+
#: model:ir.model,name:queue_job_cron_jobrunner.model_queue_job
34+
msgid "Queue Job"
35+
msgstr "Coadă sarcini"
36+
37+
#. module: queue_job_cron_jobrunner
38+
#: model:ir.actions.server,name:queue_job_cron_jobrunner.queue_job_cron_ir_actions_server
39+
#: model:ir.cron,cron_name:queue_job_cron_jobrunner.queue_job_cron
40+
#: model:ir.model.fields,field_description:queue_job_cron_jobrunner.field_ir_cron__queue_job_runner
41+
msgid "Queue Job Runner"
42+
msgstr ""
43+
44+
#. module: queue_job_cron_jobrunner
45+
#: model:ir.model,name:queue_job_cron_jobrunner.model_ir_cron
46+
msgid "Scheduled Actions"
47+
msgstr ""
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import ir_cron
2+
from . import queue_job
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright 2022 Camptocamp SA (https://www.camptocamp.com).
2+
# @author Iván Todorovich <ivan.todorovich@camptocamp.com>
3+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
4+
5+
from odoo import fields, models
6+
7+
8+
class IrCron(models.Model):
9+
_inherit = "ir.cron"
10+
11+
queue_job_runner = fields.Boolean(
12+
help="If checked, the cron is considered to be a queue.job runner.",
13+
)

0 commit comments

Comments
 (0)