ack late; check rabbitmq
This commit is contained in:
		
							parent
							
								
									010a3ff267
								
							
						
					
					
						commit
						8e399db587
					
				| 
						 | 
					@ -240,6 +240,10 @@ CELERYD_MAX_TASKS_PER_CHILD = 20
 | 
				
			||||||
# Number of concurrent workers. Defaults to the number of CPUs.
 | 
					# Number of concurrent workers. Defaults to the number of CPUs.
 | 
				
			||||||
# CELERYD_CONCURRENCY = 8
 | 
					# CELERYD_CONCURRENCY = 8
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Late ack means the task messages will be acknowledged after
 | 
				
			||||||
 | 
					# the task has been executed, not just before
 | 
				
			||||||
 | 
					CELERY_ACKS_LATE = True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
djcelery.setup_loader()
 | 
					djcelery.setup_loader()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# ==============================================
 | 
					# ==============================================
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -513,6 +513,13 @@ def check_and_run_celery():
 | 
				
			||||||
    if 'pong' in celery_status:
 | 
					    if 'pong' in celery_status:
 | 
				
			||||||
        return 'celery is running'
 | 
					        return 'celery is running'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    rabbitmq_status = os.popen('telnet localhost 5672').read()
 | 
				
			||||||
 | 
					    if 'Connected' in rabbitmq_status:
 | 
				
			||||||
 | 
					        LOG.info('Rabbitmq is running.')
 | 
				
			||||||
 | 
					    else:
 | 
				
			||||||
 | 
					        LOG.warning('Rabbitmq is not running.')
 | 
				
			||||||
 | 
					        return 'Rabbitmq is not running.'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    retries = 0
 | 
					    retries = 0
 | 
				
			||||||
    while retries < 5:
 | 
					    while retries < 5:
 | 
				
			||||||
        LOG.warning('Celery is not running.')
 | 
					        LOG.warning('Celery is not running.')
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1198,7 +1198,7 @@ def give_result(request, upload_code):  # pylint: disable=unused-argument
 | 
				
			||||||
        if CHECK_CELERY:
 | 
					        if CHECK_CELERY:
 | 
				
			||||||
            celery_status = utils.check_and_run_celery()
 | 
					            celery_status = utils.check_and_run_celery()
 | 
				
			||||||
        response.update(celery_status=celery_status, message='Result not ready')
 | 
					        response.update(celery_status=celery_status, message='Result not ready')
 | 
				
			||||||
        status_code = 202 
 | 
					        status_code = 202
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return HttpResponse(JSONUtil.dumps(response, pprint=True), status=status_code,
 | 
					    return HttpResponse(JSONUtil.dumps(response, pprint=True), status=status_code,
 | 
				
			||||||
                        content_type='application/json')
 | 
					                        content_type='application/json')
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue