在webman中自定义命令,是用workman启动监听之后,会自动生成workman日志,但是在打包二进制后,文件写入失败。
protected function execute(InputInterface $input, OutputInterface $output)
{
$name = $input->getArgument('name');
$output->writeln('Hello log_server');
$tcp_worker = new Worker('tcp://0.0.0.0:11101');
$tcp_worker->onWorkerStart = function ($tcp_worker) {
$udp_worker = new Worker('udp://0.0.0.0:11100');
$udp_worker->onMessage = function ($udp_connection, $data) use ($tcp_worker) {
$wmService = new WmService();
$x = 1;
HELL:
$len = unpack("x{$x}/C", $data)[1];
if ($len > 127) {
$len = 32768 ^ unpack("x{$x}/n", $data)[1];
$x = $x + 1;
}
$l = $x + 5;
$len1 = unpack("x{$l}/C", $data)[1];
if ($len1 > 127) {
$len1 = 32768 ^ unpack("x{$l}/n", $data)[1];
$l = $l + 1;
}
$l = $l + 1;
$data1 = unpack("x{$l}/a{$len1}", $data)[1];;
$data1 = iconv('gb2312', 'utf-8', ($data1));
$x = $len + $x + 2;
if ($x < strlen($data)) {
goto HELL;
}
Log::info($data1);
$msg_data = $wmService->getGameLogSwoole($data1, date('Y-m-d H:i:s'));
if (!empty($msg_data)) {
$wmService->gameLogsSwooleInsert($msg_data);
}
};
$udp_worker->listen();
};
Worker::runAll();
$output->writeln('运行成功');
return self::SUCCESS;
}
[root@VM-0-12-centos build]# ./webman.bin log_server start
Hello log_server
Workerman[./webman.bin] start in DEBUG mode
file_put_contents(phar:///home/www/webman/build/webman.bin/vendor/workerman/workerman/../workerman.log): Failed to open stream: phar error: open mode append not supported in file phar:///home/www/webman/build/webman.bin/vendor/workerman/workerman/Worker.php on line 2226
fopen(phar:///home/www/webman/build/webman.bin/vendor/workerman/workerman/../_home_www_webman_build_webman.bin.pid.lock): Failed to open stream: phar error: open mode append not supported in file phar:///home/www/webman/build/webman.bin/vendor/workerman/workerman/Worker.php on line 642
file_put_contents(phar:///home/www/webman/build/webman.bin/vendor/workerman/workerman/../_home_www_webman_build_webman.bin.pid): Failed to open stream: phar error: write operations disabled by the php.ini setting phar.readonly in file phar:///home/www/webman/build/webman.bin/vendor/workerman/workerman/Worker.php on line 1337
In Worker.php line 1338:
can not save pid to phar:///home/www/webman/build/webman.bin/vendor/workerman/
workerman/../_home_www_webman_build_webman.bin.pid
log_server [<name>]
centos6.9,php版本7.2,workerman/webman是直接composer安装的
workerman/workerman :v4.1.10
workerman/webman-framework :v1.5.6
webman/think-orm:v1.1.1
webman/console:v1.2.35
有可能你的配置文件config/server.php缺少了
pid_file
status_file
stdout_file
log_file
设置,参考下面配置设置下,设置到 runtime_path() 目录下感谢大佬,我是设置了,依然是这个问题,但是我已经使用 webman的 “自定义进程” 来实现了功能了,目前运行正常,非常感谢。