Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#2977] Basic implementation of background jobs via python-rq #3165

Merged
merged 24 commits into from
Sep 16, 2016
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
cc46efa
[#2977] Basic implementation of background jobs via python-rq.
torfsen Jul 14, 2016
4f50fe3
[#2977] Lazy initialization of background job queue.
torfsen Jul 15, 2016
dd2edc3
[#2977] Mark Celery features as deprecated.
torfsen Jul 18, 2016
e0afc7c
[#2977] Log exceptions raised by background jobs.
torfsen Jul 18, 2016
7ded147
[#2977] Add Redis to installation instructions.
torfsen Jul 19, 2016
b264a85
[#2977] Add `redis_url` configuration option.
torfsen Jul 19, 2016
541558a
[#2977] Add support for multiple queues.
torfsen Jul 22, 2016
b3be320
[#2977] Document requirement to namespace Redis keys.
torfsen Jul 25, 2016
e9e7e3c
[#2977] Add tests for `ckan.lib.jobs`.
torfsen Jul 25, 2016
df7e61f
[#2977] Tests for `job_*` API functions.
torfsen Jul 26, 2016
061ca31
[#2977] Tests for `paster jobs` command.
torfsen Jul 26, 2016
c8a8553
[#2977] Add `paster jobs show` command.
torfsen Jul 27, 2016
a6788db
[#2977] Document new background job system.
torfsen Jul 28, 2016
d0b56a6
[#2977] Increase verbosity of background job worker output.
torfsen Jul 28, 2016
958db3a
[#2977] Document in which CKAN version new features were added.
torfsen Jul 28, 2016
6379585
[#2977] Rename configuration option `redis_url` to `ckan.redis.url`.
torfsen Aug 22, 2016
4fcc8c1
[#2977] Remove `ckan.tests.helpers.temp_file` context manager.
torfsen Aug 22, 2016
4bd5521
[#2977] Improve docs of `ckan.tests.helpers.RecordingLogHandler`
torfsen Aug 22, 2016
74aabf9
[#2977] Add `ckan.plugins.toolkit.enqueue_job`.
torfsen Sep 12, 2016
4ef202b
[#2977] Improve wording of best practice regarding name clashes.
torfsen Sep 12, 2016
18e140b
[#2977] Don't remove ckan/config/celery-supervisor.conf after all.
torfsen Sep 12, 2016
e855b55
[#2977] Remove CKAN prefix from suggested configuration option name.
torfsen Sep 12, 2016
c3cf34e
[#2977] Change CKAN release from 2.6 to 2.7.
torfsen Sep 13, 2016
a967a9b
[#2977] Import `config` from `ckan.common` instead of `pylons`.
torfsen Sep 14, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ckan/config/deployment.ini_tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ ckan.site_id = default
#solr_url = http://127.0.0.1:8983/solr


## Redis Settings

# URL to your Redis instance, including the database to be used.
#ckan.redis.url = redis://localhost:6379/0


## CORS Settings

# If cors.origin_allow_all is true, all origins are allowed.
Expand Down
6 changes: 6 additions & 0 deletions ckan/config/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import ckan.plugins as p
import ckan.lib.helpers as helpers
import ckan.lib.app_globals as app_globals
from ckan.lib.redis import is_redis_available
import ckan.lib.render as render
import ckan.lib.search as search
import ckan.logic as logic
Expand Down Expand Up @@ -93,6 +94,10 @@ def find_controller(self, controller):
for msg in msgs:
warnings.filterwarnings('ignore', msg, sqlalchemy.exc.SAWarning)

# Check Redis availability
if not is_redis_available():
log.critical('Could not connect to Redis.')

# load all CKAN plugins
p.load_all()

Expand All @@ -105,6 +110,7 @@ def find_controller(self, controller):
'sqlalchemy.url': 'CKAN_SQLALCHEMY_URL',
'ckan.datastore.write_url': 'CKAN_DATASTORE_WRITE_URL',
'ckan.datastore.read_url': 'CKAN_DATASTORE_READ_URL',
'ckan.redis.url': 'CKAN_REDIS_URL',
'solr_url': 'CKAN_SOLR_URL',
'ckan.site_id': 'CKAN_SITE_ID',
'ckan.site_url': 'CKAN_SITE_URL',
Expand Down
43 changes: 43 additions & 0 deletions ckan/config/supervisor-ckan-worker.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
; =======================================================
; Supervisor configuration for CKAN background job worker
; =======================================================

; 1. Copy this file to /etc/supervisr/conf.d
; 2. Make sure the paths below match your setup


[program:ckan-worker]

; Use the full paths to the virtualenv and your configuration file here.
command=/usr/lib/ckan/default/bin/paster --plugin=ckan jobs worker --config=/etc/ckan/default/production.ini


; User the worker runs as.
user=www-data


; Start just a single worker. Increase this number if you have many or
; particularly long running background jobs.
numprocs=1
process_name=%(program_name)s-%(process_num)02d


; Log files.
stdout_logfile=/var/log/ckan-worker.log
stderr_logfile=/var/log/ckan-worker.log


; Make sure that the worker is started on system start and automatically
; restarted if it crashes unexpectedly.
autostart=true
autorestart=true


; Number of seconds the process has to run before it is considered to have
; started successfully.
startsecs=10

; Need to wait for currently executing tasks to finish at shutdown.
; Increase this if you have very long running tasks.
stopwaitsecs = 600

8 changes: 8 additions & 0 deletions ckan/lib/celery_app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# encoding: utf-8

'''
Celery background tasks management.

This module is DEPRECATED, use ``ckan.lib.jobs`` instead.
'''

import ConfigParser
import os
import logging
Expand All @@ -9,6 +15,8 @@

log = logging.getLogger(__name__)

log.warning('ckan.lib.celery_app is deprecated, use ckan.lib.jobs instead.')

LIST_PARAMS = """CELERY_IMPORTS ADMINS ROUTES""".split()

from celery import Celery
Expand Down
Loading