配置好之后,啟動提示錯誤!proc_get_status()expects parameter 1 to be resource,null given file 路徑。報錯1365以及1393位置處。
1365處代碼:
$process = proc_open("php \"$start_file\" -q", $descriptorspec, $pipes);
1393處代碼
$status = proc_get_status($process);
public static function forkOneWorkerForWindows($start_file)
{
$start_file = realpath($start_file);
$std_file = sys_get_temp_dir() . '/'.str_replace(array('/', "\\", ':'), '_', $start_file).'.out.txt';
$descriptorspec = array(
0 => array('pipe', 'a'), // stdin
1 => array('file', $std_file, 'w'), // stdout
2 => array('file', $std_file, 'w') // stderr
);
$pipes = array();
$process = proc_open("php \"$start_file\" -q", $descriptorspec, $pipes);
$std_handler = fopen($std_file, 'a+');
stream_set_blocking($std_handler, 0);
if (empty(static::$globalEvent)) {
static::$globalEvent = new Select();
Timer::init(static::$globalEvent);
}
$timer_id = Timer::add(0.1, function()use($std_handler)
{
Worker::safeEcho(fread($std_handler, 65535));
});
// 保存子進程句柄
static::$_processForWindows[$start_file] = array($process, $start_file, $timer_id);
}
/**
* check worker status for windows.
* @return void
*/
public static function checkWorkerStatusForWindows()
{
foreach(static::$_processForWindows as $process_data)
{
$process = $process_data[0];
$start_file = $process_data[1];
$timer_id = $process_data[2];
$status = proc_get_status($process);
if(isset($status['running']))
{
if(!$status['running'])
{
static::safeEcho("process $start_file terminated and try to restart\n");
Timer::del($timer_id);
proc_close($process);
static::forkOneWorkerForWindows($start_file);
我用Linux可以正常開啟,但是換成Windows之后就報錯,請問是什么問題,本人小白一個,求助一下,看看有沒有遇見過的。