配置好之后,启动提示错误!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之后就报错,请问是什么问题,本人小白一个,求助一下,看看有没有遇见过的。
报错一般看第一行
proc_open函数被php.ini禁用了,到 php.ini 里吧disable_function一行注释掉试下吧
谢谢,已经解决了。