Skip to content

Commit

Permalink
fix produce load bug
Browse files Browse the repository at this point in the history
  • Loading branch information
kiss291323003 committed Jan 29, 2019
1 parent dc139ee commit c1a6890
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/Command/CommandRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ function run(array $args):?string
if(empty($command)){
$command = 'help';
}else if($command != 'install'){
//预先加载配置
if(in_array('produce',$args)){
Core::getInstance()->setIsDev(false);
}
Core::getInstance()->initialize();
}
if(!CommandContainer::getInstance()->get($command)){
Expand Down
3 changes: 1 addition & 2 deletions src/Command/DefaultCommand/Start.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ public function exec(array $args): ?string
Utility::opCacheClear();
$response = Utility::easySwooleLog();
$mode = 'develop';
if(in_array('produce',$args)){
if(!Core::getInstance()->isDev()){
$mode = 'produce';
Core::getInstance()->setIsDev(false);
}
$conf = Config::getInstance();
if(in_array("d",$args) || in_array("daemonize",$args)){
Expand Down
8 changes: 5 additions & 3 deletions src/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ function __construct()
function setIsDev(bool $isDev)
{
$this->isDev = $isDev;
//变更这里的时候,例如在全局的事件里面修改的,,重新加载配置项
$this->loadEnv();
return $this;
}

Expand Down Expand Up @@ -154,6 +152,8 @@ private function sysDirectoryInit():void
if(empty($tempDir)){
$tempDir = EASYSWOOLE_ROOT.'/Temp';
Config::getInstance()->setConf('TEMP_DIR',$tempDir);
}else{
$tempDir = rtrim($tempDir,'/');
}
if(!is_dir($tempDir)){
mkdir($tempDir);
Expand All @@ -164,6 +164,8 @@ private function sysDirectoryInit():void
if(empty($logDir)){
$logDir = EASYSWOOLE_ROOT.'/Log';
Config::getInstance()->setConf('LOG_DIR',$logDir);
}else{
$logDir = rtrim($logDir,'/');
}
if(!is_dir($logDir)){
mkdir($logDir);
Expand Down Expand Up @@ -400,7 +402,7 @@ private function registerDefaultCallBack(\swoole_server $server,int $serverType)
});
}

private function loadEnv()
public function loadEnv()
{
//加载之前,先清空原来的
if($this->isDev){
Expand Down

0 comments on commit c1a6890

Please sign in to comment.