Reiniciando graciosamente as instâncias do Django Celery

4

Eu estou querendo saber qual é a melhor maneira de reiniciar o Celery sem perder nenhuma tarefa durante a reinicialização.

Atualmente, estou executando-o como um daemon usando o init.d / script fornecido com aipo - tudo está funcionando muito bem.

No entanto, precisarei reiniciá-lo (acho?) para ver as atualizações de código. Minha preocupação é que, se alguém enviar uma foto e quisermos processá-la durante aquela janela de 5 ou mais que o aipo está reiniciando, a tarefa será perdida para sempre e começaremos a ver problemas estranhos.

Existe uma maneira sugerida de recarregar o código para o aipo sem perder nenhuma transação nesse meio tempo?

Obrigado,

Phil

    
por philipk 25.08.2011 / 00:55

1 resposta

2

Você pode seguramente reiniciar o celery worker sem perder nenhuma tarefa com o sinal TERM. Assim, o aipo terminará as tarefas atuais e morrerá.

Se você quiser que suas tarefas sejam repetidas se algo der errado, você também poderá usar a opção acks_late (Task.acks_late / CELERY_ACKS_LATE).

P: Como posso desligar o trabalhador com segurança? (de: link )

Answer: Use the TERM signal, and the worker will finish all currently executing jobs and shut down as soon as possible. No tasks should be lost.

You should never stop worker with the KILL signal (-9), unless you’ve tried TERM a few times and waited a few minutes to let it get a chance to shut down. As if you do tasks may be terminated mid-execution, and they will not be re-run unless you have the acks_late option set (Task.acks_late / CELERY_ACKS_LATE).

Para parar o trabalhador (de: link )

P: Parando o trabalhador

Shutdown should be accomplished using the TERM signal.

Para enviar um sinal TERM, use o comando linux KILL (de: link )

kill - terminate a process SYNOPSIS

kill [ -s signal | -p ] [ -a ] [ -- ] pid ... kill -l [ signal ] DESCRIPTION

The command kill sends the specified signal to the specified process or process group. If no signal is specified, the TERM signal is sent. The TERM signal will kill processes which do not catch this signal. For other processes, it may be necessary to use the KILL (9) signal, since this signal cannot be caught.

    
por 25.06.2014 / 01:25