From 6581d4482b8a84b63c151b93a8cdc8685a3879fd Mon Sep 17 00:00:00 2001 From: inhere Date: Wed, 29 May 2019 20:33:33 +0800 Subject: [PATCH] up: will auto find php file --- app/Command/ServeCommand.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/Command/ServeCommand.php b/app/Command/ServeCommand.php index 4a2d8e5..6642344 100644 --- a/app/Command/ServeCommand.php +++ b/app/Command/ServeCommand.php @@ -10,6 +10,7 @@ use Swoft\Console\Annotation\Mapping\CommandOption; use Swoft\Console\Helper\Show; use Swoft\Console\Input\Input; +use Swoft\Stdlib\Helper\Sys; use Swoole\Process; use function array_map; use function date; @@ -87,6 +88,14 @@ private function collectInfo(Input $input): bool $this->debug = $input->getBoolOpt('debug'); $this->phpBin = $input->getOpt('php-bin'); + if ($this->phpBin === 'php') { + [$ok, $ret, ] = Sys::run('which php'); + + if ($ok === 0) { + $this->phpBin = \trim($ret); + } + } + $interval = (int)$input->getOpt('interval', 3); if ($interval < 0 || $interval > 15) { $interval = 3; @@ -111,9 +120,10 @@ private function collectInfo(Input $input): bool // $cmd = "php {$pwd}/bin/swoftcli sys:info"; $this->entryFile = $this->targetPath . '/' . $this->binFile; - output()->aList([ + Show::aList([ 'current pid' => getmypid(), 'current dir' => $workDir, + 'php binFile' => $this->phpBin, 'target path' => $this->targetPath, 'watch dirs' => $this->watchDir, 'entry file' => $this->entryFile,