celery使用详细
安装过程就不说了。。。
先配置rabbitmq
Setting up RabbitMQ
To use celery we need to create a RabbitMQ user, a virtual host and allow that user access to that virtual host:
$ rabbitmqctl add_user myuser mypassword
$ rabbitmqctl add_vhost myvhost
$ rabbitmqctl set_permissions -p myvhost myuser ".*" ".*" ".*"
创建消息队列执行的服务器,用户名等等。。。
celeryd 参数 配置
-c, --concurrency
Number of child processes processing the queue. The default is the number of CPUs available on your system.
-f, --logfile
Path to log file. If no logfile is specified, stderr is used.
-l, --loglevel
Logging level, choose between DEBUG, INFO, WARNING, ERROR, CRITICAL, or FATAL.
-n, --hostname
Set custom hostname.
-B, --beat
Also run the celerybeat periodic task scheduler. Please note that there must only be one instance of this service.
-Q, --queues
List of queues to enable for this worker, separated by comma. By default all configured queues are enabled. Example: -Q video,image
-I, --include
Comma separated list of additional modules to import. Example: -I foo.tasks,bar.tasks
-s, --schedule
Path to the schedule database if running with the -B option. Defaults to celerybeat-schedule. The extension ”.db” will be appended to the filename.
--scheduler
Scheduler class to use. Default is celery.beat.PersistentScheduler
-E, --events
Send events that can be captured by monitors like celerymon.
--purge, --discard
Discard all waiting tasks before the daemon is started. WARNING: This is unrecoverable, and the tasks will be deleted from the messaging server.
--time-limit
Enables a hard time limit (in seconds) for tasks.
--soft-time-limit
Enables a soft time limit (in seconds) for tasks.
--maxtasksperchild
Maximum number of tasks a pool worker can execute before it’s terminated and replaced by a new worker.
class celery.bin.celeryd.WorkerCommand(app=None, get_app=None)
enable_config_from_cmdline = True
get_options()
namespace = 'celeryd'
run(*args, **kwargs)
supports_args = False
celery.bin.celeryd.main()