Skip to content

Commit 08ebf36

Browse files
committed
Merge pull request #92 from IAlwaysBeCoding/patch-4
Added an example of mrq-config.py on the docs
2 parents d0ce3b3 + f5df3f6 commit 08ebf36

1 file changed

Lines changed: 71 additions & 2 deletions

File tree

docs/configuration.md

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,78 @@ Most of the time, you want to set all your configuration in a `mrq-config.py` fi
1010

1111
On Heroku, environment variables are very handy because they can be set like `heroku config:set MRQ_REDIS=redis://127.0.0.1:6379`
1212

13+
###mrq-config.py
14+
Remember, put mrq-config.py in your workers directory.
15+
```python
16+
17+
""" Redis and MongoDB settings
18+
"""
19+
#MongoDB settings
20+
MONGODB_JOBS = "mongodb://127.0.0.1:27017/mrq" # MongoDB URI for the jobs, scheduled_jobs & workers database.Defaults to mongodb://127.0.0.1:27017/mrq
21+
MONGODB_LOGS = 1 #MongoDB URI for the logs database."0" will disable remote logs, "1" will use main MongoDB.Defaults to 1
22+
MONGODB_LOGS_SIZE = None #If provided, sets the log collection to capped to that amount of bytes.
23+
NO_MONGODB_ENSURE_INDEXES = None #If provided, skip the creation of MongoDB indexes at worker startup.
24+
25+
#Redis settings
26+
REDIS = "redis://127.0.0.1:6379" #Redis URI.Defaults to redis://127.0.0.1:6379
27+
REDIS_PREFIX = "mrq" #Redis key prefix.Default to "mrq".
28+
REDIS_MAX_CONNECTIONS = 1000 #Redis max connection pool size.Defaults to 1000.
29+
REDIS_TIMEOUT = 30 #Redis connection pool timeout to wait for an available connection.Defaults to 30.
30+
31+
"""General MrQ settings
32+
"""
33+
TRACE_GREENLETS = False #Collect stats about each greenlet execution time and switches.Defaults to False.
34+
TRACE_MEMORY = False #Collect stats about memory for each task. Incompatible with `GREENLETS` > 1. Defaults to False.
35+
TRACE_IO = True #Collect stats about all I/O operations.Defaults to True.
36+
PRINT_MONGODB = False #Print all MongoDB requests.Defaults to False.
37+
TRACE_MEMORY_TYPE = "" #Create a .png object graph in trace_memory_output_dir with a random object of this type.
38+
TRACE_MEMORY_OUTPUT_DIR = "memory_traces" #Directory where to output .pngs with object graphs.Defaults to folder memory_traces.
39+
PROFILE = False #Run profiling on the whole worker.Defaults to False.
40+
NAME = None #Specify a different name.
41+
QUIET = False #Don\'t output task logs.Defaults to False.
42+
CONFIG = None #Path of a config file.
43+
WORKER_CLASS = "mrq.worker.Worker" #Path to a custom worker class.Defaults to "mrq.worker.Worker".
44+
VERSION = False #Prints current MRQ version.Defaults to False.
45+
NO_IMPORT_PATCH = False #Skips patching __import__ to fix gevent bug #108.Defaults to False.
46+
ADD_NETWORK_LATENCY = 0 #Adds random latency to the network calls, zero to N seconds. Can be a range (1-2)').Defaults to 0.
47+
DEFAULT_JOB_RESULT_TTL = 604800 #Seconds the results are kept in MongoDB when status is success.Defaults to 604800 seconds which is 7 days.
48+
DEFAULT_JOB_ABORT_TTL = 86400 #Seconds the tasks are kept in MongoDB when status is abort.Defaults to 86400 seconds which is 1 day.
49+
DEFAULT_JOB_CANCEL_TTL = 86400 #Seconds the tasks are kept in MongoDB when status is cancelDefaults to 86400 seconds which is 1 day.
50+
DEFAULT_JOB_TIMEOUT = 3600 #In seconds, delay before interrupting the job.Defaults to 3600 seconds which is 1 hour.
51+
DEFAULT_JOB_MAX_RETRIES = 3 #Set the status to "maxretries" after retrying that many times.Defaults to 3 seconds.
52+
DEFAULT_JOB_RETRY_DELAY = 3 #Seconds before a job in retry status is requeued again.Defaults to 3 seconds.
53+
USE_LARGE_JOB_IDS = False #Do not use compacted job IDs in Redis. For compatibility with 0.1.x only. Defaults to
54+
55+
""" mrq-worker settings
56+
"""
57+
QUEUES = ("default",) # The queues to listen on.Defaults to default , which will listen on all queues.
58+
MAX_JOBS = 0 #Gevent:max number of jobs to do before quitting. Temp workaround for memory leaks.Defaults to 0
59+
MAX_MEMORY = 1 #Max memory (in Mb) after which the process will be shut down. Use with PROCESS = [1-N] to have supervisord automatically respawn the worker when this happens.Defaults to 1
60+
GRENLETS = 1 #Max number of greenlets to use.Defaults to 1.
61+
PROCESSES = 0 #Number of processes to launch with supervisord.Defaults to 0.
62+
SUPERVISORD_TEMPLATE = "supervisord_templates/default.conf" #Path of supervisord template to use. Defaults to supervisord_templates/default.conf.
63+
SCHEDULER = False #Run the scheduler.Defaults to False.
64+
SCHEDULER_INTERVAL = 60 #Seconds between scheduler checks.Defaults to 60 seconds, only ints are acceptable.
65+
REPORT_INTERVAL = 10.5 #Seconds between worker reports to MongoDB.Defaults to 10 seconds, floats are acceptable too.
66+
REPORT_FILE = "" #Filepath of a json dump of the worker status. Disabled if none.
67+
ADMIN_PORT = 0 #Start an admin server on this port, if provided. Incompatible with --processes.Defaults to 0
68+
ADMIN_IP = "127.0.0.1" #IP for the admin server to listen on. Use "0.0.0.0" to allow access from outside.Defaults to 127.0.0.1.
69+
LOCAL_IP = "" #Overwrite the local IP, to be displayed in the dashboard.
70+
MAX_LATENCY = 3 #Max seconds while worker may sleep waiting for a new job.Can be < 1 and a float value.
71+
72+
""" mrq-dashboard settings
73+
"""
74+
DASHBOARD_HTTPAUTH = "" #HTTP Auth for the Dashboard. Format is user
75+
DASHBOARD_QUEUE = "default" #Default queue for dashboard actions.
76+
DASHBOARD_PORT = 5555 #Use this port for mrq-dashboard.Defaults to port 5555.
77+
DASHBOARD_IP = "0.0.0.0" #Bind the dashboard to this IP. Default is 0.0.0.0, use 127.0.0.1 to restrict access.
78+
79+
80+
81+
```
1382
## Tasks configuration
1483

15-
Tasks can alter some default values of their jobs. These values can be configured in the config file like this (values below are :
84+
Tasks can alter some default values of their jobs. These values can be configured in the mrq-config.py file like this (values below are :
1685

1786
```python
1887

@@ -38,4 +107,4 @@ TASKS = {
38107
}
39108
}
40109

41-
```
110+
```

0 commit comments

Comments
 (0)