mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-07 05:38:11 +08:00
Configuration is now through a dict.
This commit is contained in:
+34
-61
@@ -5,78 +5,51 @@ from django.conf import settings
|
|||||||
|
|
||||||
VERSION = '0.1.0'
|
VERSION = '0.1.0'
|
||||||
|
|
||||||
"""
|
|
||||||
Redis server connection
|
|
||||||
"""
|
|
||||||
try:
|
try:
|
||||||
REDIS = settings.Q_REDIS
|
conf = settings.Q_CLUSTER
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
REDIS = {}
|
conf = {}
|
||||||
"""
|
|
||||||
Prefixes the Redis keys. Defaults to django_q
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
PREFIX = settings.Q_PREFIX
|
|
||||||
except AttributeError:
|
|
||||||
PREFIX = 'django_q'
|
|
||||||
|
|
||||||
"""
|
# Redis server configuration . Follows standard redis keywords
|
||||||
Sets the logging level for the app
|
REDIS = conf.get('redis', {})
|
||||||
"""
|
|
||||||
try:
|
|
||||||
LOG_LEVEL = settings.Q_LOG_LEVEL
|
|
||||||
except AttributeError:
|
|
||||||
LOG_LEVEL = "INFO"
|
|
||||||
|
|
||||||
"""
|
# Name of the cluster or site. For when you run multiple sites on one redis server
|
||||||
Using Django's secret key to sign task packages
|
PREFIX = conf.get('name', 'default')
|
||||||
"""
|
|
||||||
|
# Log output level
|
||||||
|
LOG_LEVEL = conf.get('log_level', 'INFO')
|
||||||
|
|
||||||
|
# Maximum number of successful tasks kept in the database. 0 saves everything. -1 saves none
|
||||||
|
# Failures are always saved
|
||||||
|
SAVE_LIMIT = conf.get('save_limit', 250)
|
||||||
|
|
||||||
|
# Number of workers in the pool. Default is cpu count. +2 for monitor and pusher
|
||||||
|
WORKERS = conf.get('workers', cpu_count())
|
||||||
|
|
||||||
|
# Sets compression of redis packages
|
||||||
|
COMPRESSED = conf.get('compress', False)
|
||||||
|
|
||||||
|
# Number of tasks each worker can handle before it gets recycled. Useful for releasing memory
|
||||||
|
RECYCLE = conf.get('recycle', 1000)
|
||||||
|
|
||||||
|
# The Django Admin label for this app
|
||||||
|
LABEL = conf.get('label', 'Django Q')
|
||||||
|
|
||||||
|
# Use the secret key for package signing
|
||||||
try:
|
try:
|
||||||
SECRET_KEY = settings.SECRET_KEY
|
SECRET_KEY = settings.SECRET_KEY
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
SECRET_KEY = 'omgicantbelieveyoudonthaveasecretkey'
|
SECRET_KEY = 'omgicantbelieveudonthaveasecretkey'
|
||||||
|
|
||||||
"""
|
# Getting the signal names
|
||||||
SAVE_LIMIT limits the amount of successful task executions saved to the database.
|
|
||||||
Set this to 0 for no limits.
|
|
||||||
Failures are not limited.
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
SAVE_LIMIT = settings.Q_SAVE_LIMIT
|
|
||||||
except AttributeError:
|
|
||||||
SAVE_LIMIT = 100
|
|
||||||
|
|
||||||
try:
|
|
||||||
WORKERS = settings.Q_WORKERS
|
|
||||||
except AttributeError:
|
|
||||||
WORKERS = cpu_count()
|
|
||||||
|
|
||||||
"""
|
|
||||||
Turns compression on/off for task packages
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
COMPRESSED = settings.Q_COMPRESSED
|
|
||||||
except AttributeError:
|
|
||||||
COMPRESSED = False
|
|
||||||
|
|
||||||
try:
|
|
||||||
USE_TZ = settings.USE_TZ
|
|
||||||
except AttributeError:
|
|
||||||
USE_TZ = False
|
|
||||||
|
|
||||||
"""
|
|
||||||
Getting the SIGNAL names
|
|
||||||
"""
|
|
||||||
SIGNAL_NAMES = dict((getattr(signal, n), n) for n in dir(signal) if n.startswith('SIG') and '_' not in n)
|
SIGNAL_NAMES = dict((getattr(signal, n), n) for n in dir(signal) if n.startswith('SIG') and '_' not in n)
|
||||||
|
|
||||||
"""
|
# The redis list key
|
||||||
Redis List name
|
Q_LIST = 'django_q:{}:q'.format(PREFIX)
|
||||||
"""
|
# The redis stats key
|
||||||
Q_LIST = '{}:q'.format(PREFIX)
|
Q_STAT = 'django_q:{}:cluster'.format(PREFIX)
|
||||||
|
|
||||||
"""
|
# Cluster status
|
||||||
Cluster status
|
|
||||||
"""
|
|
||||||
STARTING = 'Starting'
|
STARTING = 'Starting'
|
||||||
RUNNING = 'Running'
|
RUNNING = 'Running'
|
||||||
STOPPED = 'Stopped'
|
STOPPED = 'Stopped'
|
||||||
|
|||||||
@@ -103,13 +103,4 @@ LOGGING = {
|
|||||||
STATIC_URL = '/static/'
|
STATIC_URL = '/static/'
|
||||||
|
|
||||||
# Django Q specific
|
# Django Q specific
|
||||||
Q_PREFIX = 'test_django_q'
|
Q_CLUSTER = {'name': 'django_q_test'}
|
||||||
|
|
||||||
Q_REDIS = {
|
|
||||||
#'host': 'localhost',
|
|
||||||
#'port': 6379,
|
|
||||||
# 'db': 1,
|
|
||||||
# 'socket_timeout': 3,
|
|
||||||
# 'password': '...',
|
|
||||||
# 'unix_socket_path': ''
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user