chrisboulton / php-resque

PHP port of resque (Workers and Queueing)
MIT License
3.43k stars 759 forks source link

Write child worker PID to PIDFILE for multiple workers #187

Open Hikariii opened 10 years ago

Hikariii commented 10 years ago

About https://github.com/chrisboulton/php-resque#running-multiple-workers.

Spawning multiple workers via the COUNT variable ignores the PIDFILE environment var. It would be nice if the file defined in the PIDFILE environment var would be used to log the PID for each child process. Maybe each child process could append its own PID to the file. In this way an external app can keep track of the spawned child processes.

See https://github.com/chrisboulton/php-resque/blob/master/bin/resque#L112-L116 for current implementation.

Rockstar04 commented 10 years ago

The more I think about this the more complex I realize it would need to be, would something like the GOD script that comes with the ruby version work for you? I modified the ruby version to manage my PHP workers and it keeps track of all your PIDs for you.

Looking over some other issues and PR's you might want to take a look at #83 it seems to track forked worker PIDs https://github.com/chrisboulton/php-resque/pull/83/files#diff-e38fd1eaf04f5072dbc4cf2f64534e5fR125

danhunsaker commented 10 years ago

Maintaining a PID file for multiple processes is ridiculously difficult. The better approach is to keep the parent process intact and keep its PID in the PID file instead. PR #83 provides this functionality (though it's a bit out of date, now). I, for one, do not recommend the approach presented in the issue description.