Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

supervisord process does not reload new php code

For synchronous processing, we use supervisord with a beanstalkd queue. The application and worker code is all written in php (using SlmQueue). I notice that when we deploy new code, the new code isn't working for the worker processes. I am not quite sure what's the reason, but what I did found out:

  1. service supervisor restart does not restart the process (the PID keeps the same)
  2. supervisorctl reload does reload all the processes, the new code is used for now
  3. supervisorctl has no way (as I understand it) to reload only one program and keep the others still running

I am looking for a way to deploy new code (working via ansible and a git checkout) and no need to restart the complete supervisor process with all its children. We run Ubuntu 12.04 machines with PHP 5.5. I guess the opcode cache may play a role, but I am unsure how to trigger a flush for these specific files.

Is there any way to gracefully reload the processes and not completely reload all supervisord child processes? Or if the reason might be the opcode cache, is it possible to flush the cache with a certain trigger?

like image 473
Jurian Sluiman Avatar asked May 05 '14 19:05

Jurian Sluiman


People also ask

How do I restart my Supervisord process?

Start / Stop a Service To start a non-running service or stop a running one, use supervisorctl start my-daemon and supervisorctl stop my-daemon . To restart a service, you can also use supervisorctl restart my-daemon .

How do I know if my boss is running or not?

The supervisor service runs automatically after installation. You can check its status: sudo systemctl status supervisor.

How Laravel queue works?

Laravel queues provide a unified API across a variety of different queue backends, such as Beanstalk, Amazon SQS, Redis, or even a relational database. Queues allow you to defer the processing of a time consuming task, such as sending an email, until a later time.

How does Laravel supervisor work?

The supervisor is a process manager which Laravel suggests to use as a process monitor for queue workers. It will automatically start the queue worker in the background, even after the system has booted and will automatically restart the worker if the worker exits unexpectedly.


1 Answers

You can use supervisorctl to restart only one process.

supervisorctl -c /etc/supervisord/supervisord.conf

Once you are in the supervisor subshell you can use status and restart to reload your job. Consider the following example where I reload flower

supervisor> status
   beat_worker:beat_worker_00          RUNNING   pid 32274, uptime 0:27:45
   flower                              RUNNING   pid 32275, uptime 0:27:45
   workers:worker_wkrone_00            RUNNING   pid 32278, uptime 0:27:45
   workers:worker_wkrtwo_00            RUNNING   pid 32276, uptime 0:27:45
   workers:worker_wkrthree_00          RUNNING   pid 32277, uptime 0:27:45

supervisor> restart flower
   flower: stopped
   flower: started

and now if you do a status again you will see that the pid of flower has changed.

supervisor> status
   beat_worker:beat_worker_00          RUNNING   pid 32274, uptime 0:28:13
   flower                              RUNNING   pid 32713, uptime 0:00:08
   workers:worker_wkrone_00            RUNNING   pid 32278, uptime 0:28:13
   workers:worker_wkrtwo_00            RUNNING   pid 32276, uptime 0:28:13
   workers:worker_wkrthree_00          RUNNING   pid 32277, uptime 0:28:13

Then just do a ctrl -d to exit the supervisord shell. If you inspect the output of status you will see that the pid of the job changed and the uptime count restarted.

like image 69
Jeff Sheffield Avatar answered Oct 23 '22 14:10

Jeff Sheffield