diff --git a/test/Resque/Tests/bootstrap.php b/test/Resque/Tests/bootstrap.php index e21707c..c7ded09 100644 --- a/test/Resque/Tests/bootstrap.php +++ b/test/Resque/Tests/bootstrap.php @@ -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