Skip to content

Instantly share code, notes, and snippets.

@jbub
Created February 22, 2018 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbub/34857c2ae8c48b5be5f99097b94680aa to your computer and use it in GitHub Desktop.
Save jbub/34857c2ae8c48b5be5f99097b94680aa to your computer and use it in GitHub Desktop.
from celery import Celery
from celery.utils.log import get_task_logger
logger = get_task_logger(__name__)
app = Celery('cel')
app.config_from_object('celeryconfig')
@app.task
def runCli(site, namespace, module, console, command, host=None):
logger.info('site={0} namespace={1} module={2} console={3} command={4} host={5}'.format(site, namespace, module, console, command, host))
return 123
from kombu import Queue
broker_url = 'redis://localhost:6379/4'
result_backend = 'redis://localhost:6379/5'
task_serializer = 'json'
result_serializer = 'json'
task_routes = {
'cel.runCli': {
'queue': 'cel',
'routing_key': 'cel',
},
}
worker_log_format = '[%(asctime)s] %(message)s'
worker_task_log_format = '[%(asctime)s] [%(task_name)s] %(message)s'
from cel import runCli
kwargs = {
'site': 123,
'namespace': 432,
'module': 423,
'console': 4324,
'command': 1231,
'host': None,
}
runCli.apply_async(kwargs=kwargs)
celery -A cel worker -n cel@%h -E -l info --concurrency=1 -Q cel -f /var/log/blabla/%n-%i.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment