Skip to content

Commit

Permalink
up: will auto find php file
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed May 29, 2019
1 parent 9a8c16d commit 6581d44
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion app/Command/ServeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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,
Expand Down

0 comments on commit 6581d44

Please sign in to comment.