Beispiel #1
0
 /**
  * fork() helper method for php-resque that handles issues PHP socket
  * and phpredis have with passing around sockets between child/parent
  * processes.
  *
  * Will close connection to Redis before forking.
  *
  * @return int Return vars as per pcntl_fork()
  */
 public static function fork()
 {
     if (!function_exists('pcntl_fork')) {
         return -1;
     }
     // Close the connection to Redis before forking.
     // This is a workaround for issues phpredis has.
     self::$redis = null;
     $pid = pcntl_fork();
     if ($pid === -1) {
         throw new \RuntimeException('Unable to fork child worker.');
     }
     return $pid;
 }