Skip to content

Commit ece1b7a

Browse files
committed
Migrate to a dedicated cron_jobs module + rqcron command
Signed-off-by: tdruez <[email protected]>
1 parent ed2cc23 commit ece1b7a

File tree

4 files changed

+22
-82
lines changed

4 files changed

+22
-82
lines changed

dje/cron_jobs.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#
2+
# Copyright (c) nexB Inc. and others. All rights reserved.
3+
# DejaCode is a trademark of nexB Inc.
4+
# SPDX-License-Identifier: AGPL-3.0-only
5+
# See https://github.com/aboutcode-org/dejacode for support or download.
6+
# See https://aboutcode.org for more information about AboutCode FOSS projects.
7+
#
8+
9+
from rq import cron
10+
11+
from dje.tasks import update_vulnerabilities
12+
13+
14+
cron.register(
15+
func=update_vulnerabilities,
16+
queue_name="default",
17+
# cron=settings.DEJACODE_VULNERABILITIES_CRON, # 3am daily by default
18+
cron="0 * * * *", # Every hour
19+
job_timeout=3600, # 1 hour
20+
)

dje/management/commands/cronjobs.py

Lines changed: 0 additions & 80 deletions
This file was deleted.

dje/tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def scancodeio_submit_scan(uris, user_uuid, dataspace_uuid):
122122
scancodeio.submit_scan(uri, user_uuid, dataspace_uuid)
123123

124124

125-
@job("default", timeout="3h")
125+
@job("default", timeout=3600)
126126
def update_vulnerabilities():
127127
"""Fetch vulnerabilities for all Dataspaces that enable vulnerablecodedb access."""
128128
from vulnerabilities.fetch import fetch_from_vulnerablecode

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ services:
6666

6767
scheduler:
6868
build: .
69-
command: wait-for-it web:8000 -- sh -c "./manage.py cronjobs"
69+
command: wait-for-it web:8000 -- sh -c "./manage.py rqcron dje.cron_jobs --logging-level DEBUG"
7070
env_file:
7171
- docker.env
7272
volumes:

0 commit comments

Comments
 (0)