Skip to content

Commit

Permalink
mkdir错误抑制
Browse files Browse the repository at this point in the history
运行目录增加gitignore
  • Loading branch information
skidu committed Jan 24, 2017
1 parent e24a155 commit 4bf00ae
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 7 additions & 4 deletions src/Commands/BaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Commands/CreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ 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}");
}

$workspace = $appPath . DIRECTORY_SEPARATOR . ucfirst($workerName);
if (is_dir($workspace)) {
throw new \Exception("directory exists: {$workspace}");
}
if (!mkdir($workspace)) {
if (!@mkdir($workspace)) {
throw new \Exception("create app directory failed: {$workspace}");
}

Expand Down

0 comments on commit 4bf00ae

Please sign in to comment.