> On Tue, Sep 23, 2014 at 08:30:15AM +0200, Roberto De Ioris wrote: >> >> > Ciao a tutti, >> > >> > >> > sto cercando la configrazione ottimale per fare partire celery con >> > django in produzione. >> > >> > Uso nginx + uwsgi per l'applicazione principale e credevo leggendo [1] >> > [2] che smart-attach-daemon avrebbe potuo risolvere il problema di >> > garantirmi che un reload di uwsgi (uwsgi --reload) inviasse un segnale >> > al processo di celery. >> > >> > Forse ho compreso male la documentazione che in effetti non dice >> > esplicitamente cosa dovrebbe succedere ma solo :: >> > >> > >> > Pidfile governed processes can survive death or reload of the master >> > so long as their pidfiles are available and the pid contained >> > therein matches a running pid. This is the best choice for processes >> > requiring longer persistence, and for which a brutal kill could mean >> > loss of data such as a database. >> > >> >> smart-attach-daemon serve proprio ad evitare che un demone venga ucciso >> durante un riavvio. Effettivamente celery (almeno nella mia mente) e' >> uno >> di quei servizi che dovrebbe andare per fatti suoi, e quindi >> smart-attach-daemon e' l'approggio giusto. >> >> Mi pare di capire pero' che tu invece vuoi che a ogni reload corrisponda >> anche un restart di celery, in questo caso attach-daemon e' quello che >> ti >> serve. >> >> Eventualmente con attach-daemon2 hai un controllo maggiore sul >> comportamento: >> >> https://github.com/unbit/uwsgi-docs/blob/master/AttachingDaemons.rst#--attach-daemon2 > > Sarebbe esattamente quello che cerco, ma non riesco assolutamente a > vedere alcun segnale. > > La mia conf è: > > celery_pid = /var/run/uwsgi/cogema-celery.pid > attach-daemon2 = cmd=/usr/local/sbin/test-signals.py > %(celery_pid),pidfile=%(celery_pid),stopsignal=3,reloadsignal=15 > > La script test-signals.py è riportata in fondo. > Quando io faccio partire uwsgi nei log leggo: > > [uwsgi-daemons] found valid/active pidfile for > "/usr/local/sbin/test-signals.py /var/run/uwsgi/cogema-celery.pid" (pid: > 31952) > > Ma poi nessun segnale arriva al processo test-signals.py. Se da > console per prova eseguo kill -3 31952, vedo subito il log del segnale > arrivato. > >
--attach-daemon2 (e piu' in generale tutte le opzioni che finiscono con '2') sono le versioni user-unfriendly :P che ti permettono di modificare i pattern prestabiliti agendo direttamente sulle strutture interne. Nel caso specifico, settando un pidfile stai forzando la modalita' smart, che non e' quella che vuoi tu. cmd=/usr/local/sbin/test-signals.py,stopsignal=3,reloadsignal=15 e' sufficiente a fare quello che vuoi. Quando lo imposterai per celery, accertati che celery non vada in background (detach/daemonize), anche se mi sembra che nelle versioni attuali sia il default. -- Roberto De Ioris http://unbit.it _______________________________________________ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python