diff --git a/src/Commands/BaseCommand.php b/src/Commands/BaseCommand.php index 93213d2..f48c2d2 100644 --- a/src/Commands/BaseCommand.php +++ b/src/Commands/BaseCommand.php @@ -47,23 +47,26 @@ protected function initPidFile($pidFile=null) protected function initRunConfFile() { $runConfFile = config('workerman.run_conf'); - $this->createRunFile($runConfFile, 'runtime config file'); + $this->createRunFile($runConfFile, 'runtime config file', true); $this->runConfFile = $runConfFile; return true; } - private function createRunFile($file, $type) + private function createRunFile($file, $type, $ignore=false) { $directory = dirname($file); - if (!is_dir($directory) && !mkdir($directory)) { + if (!is_dir($directory) && !@mkdir($directory)) { throw new \Exception("can not create directory: {$directory}"); } - if (!is_file($file) && ! touch($file)) { + if (!is_file($file) && !touch($file)) { throw new \Exception("create {$type} failed: {$file}"); } if (!is_writable($file)) { throw new \Exception("{$type} can not been written: {$file}"); } + if(!is_file($directory.'/.gitignore')) { + file_put_contents($directory.'/.gitignore', '*'); + } return true; } diff --git a/src/Commands/CreateCommand.php b/src/Commands/CreateCommand.php index 051a57a..cc286fc 100644 --- a/src/Commands/CreateCommand.php +++ b/src/Commands/CreateCommand.php @@ -11,7 +11,7 @@ public function fire() $workerName = $this->argument('name'); $config = config('workerman'); $appPath = $config['app_path']; - if (!is_dir($appPath) && !mkdir($appPath)) { + if (!is_dir($appPath) && !@mkdir($appPath)) { throw new \Exception("create app directory failed: {$appPath}"); } @@ -19,7 +19,7 @@ public function fire() if (is_dir($workspace)) { throw new \Exception("directory exists: {$workspace}"); } - if (!mkdir($workspace)) { + if (!@mkdir($workspace)) { throw new \Exception("create app directory failed: {$workspace}"); }