mirror of
https://github.com/idanoo/php-resque.git
synced 2024-11-22 00:11:53 +00:00
Fixes unit test reliability
- redis-server is killed only from parent process, not from a worker - sleeps for half a second after starting server
This commit is contained in:
parent
27758b47be
commit
2ae54583f0
@ -30,6 +30,7 @@ if($returnVar != 0) {
|
||||
}
|
||||
|
||||
exec('cd ' . TEST_MISC . '; redis-server ' . REDIS_CONF, $output, $returnVar);
|
||||
usleep(500000);
|
||||
if($returnVar != 0) {
|
||||
echo "Cannot start redis-server.\n";
|
||||
exit(1);
|
||||
@ -46,8 +47,11 @@ if(!preg_match('#^\s*port\s+([0-9]+)#m', $config, $matches)) {
|
||||
Resque::setBackend('localhost:' . $matches[1]);
|
||||
|
||||
// Shutdown
|
||||
function killRedis()
|
||||
function killRedis($pid)
|
||||
{
|
||||
if (getmypid() !== $pid) {
|
||||
return; // don't kill from a forked worker
|
||||
}
|
||||
$config = file_get_contents(REDIS_CONF);
|
||||
if(!preg_match('#^\s*pidfile\s+([^\s]+)#m', $config, $matches)) {
|
||||
return;
|
||||
@ -76,7 +80,7 @@ function killRedis()
|
||||
unlink($filename);
|
||||
}
|
||||
}
|
||||
register_shutdown_function('killRedis');
|
||||
register_shutdown_function('killRedis', getmypid());
|
||||
|
||||
if(function_exists('pcntl_signal')) {
|
||||
// Override INT and TERM signals, so they do a clean shutdown and also
|
||||
|
Loading…
Reference in New Issue
Block a user