@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | /** |
| 15 | 15 | * @var $type |
| 16 | 16 | */ |
| 17 | - public $type='project'; |
|
| 17 | + public $type = 'project'; |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * @var array |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | /** |
| 32 | 32 | * @var $commandRule |
| 33 | 33 | */ |
| 34 | - public $commandRule=[]; |
|
| 34 | + public $commandRule = []; |
|
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * @method create |
@@ -46,15 +46,15 @@ discard block |
||
| 46 | 46 | $this->argument['exceptionNamespace'] = app()->namespace()->exception(); |
| 47 | 47 | $this->argument['resourcePath'] = app()->path()->appResourche(); |
| 48 | 48 | |
| 49 | - $recursiveDefaultDirectory = explode("\\",$this->argument['project']);
|
|
| 49 | + $recursiveDefaultDirectory = explode("\\", $this->argument['project']);
|
|
| 50 | 50 | $this->argument['applicationName'] = pos($recursiveDefaultDirectory); |
| 51 | 51 | $recursiveDefaultDirectory[] = 'V1'; |
| 52 | 52 | $recursiveDefaultDirectoryList = []; |
| 53 | 53 | |
| 54 | - foreach (array_slice($recursiveDefaultDirectory,1) as $defaultDirectory){
|
|
| 54 | + foreach (array_slice($recursiveDefaultDirectory, 1) as $defaultDirectory) {
|
|
| 55 | 55 | |
| 56 | - $recursiveDefaultDirectoryList[]=$defaultDirectory; |
|
| 57 | - $this->directory[$defaultDirectory.'Path'] = $this->projectPath().''.implode("/",$recursiveDefaultDirectoryList);
|
|
| 56 | + $recursiveDefaultDirectoryList[] = $defaultDirectory; |
|
| 57 | + $this->directory[$defaultDirectory.'Path'] = $this->projectPath().''.implode("/", $recursiveDefaultDirectoryList);
|
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | //$this->directory['optionalDir'] = $this->optional(); |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | //$this->directory['sourceDir'] = $this->sourceDir(); |
| 81 | 81 | //$this->directory['sourceSupportDir'] = $this->sourceSupportDir(); |
| 82 | 82 | //$this->directory['sourceSupportTraitDir'] = $this->sourceSupportDir().'/Traits'; |
| 83 | - $this->directory['exceptionDir'] = app()->path()->exception(); |
|
| 83 | + $this->directory['exceptionDir'] = app()->path()->exception(); |
|
| 84 | 84 | |
| 85 | 85 | //set project directory |
| 86 | 86 | $this->file->makeDirectory($this); |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | $this->touch['app/gitignore'] = $this->projectPath().'/.gitignore'; |
| 134 | 134 | $this->touch['app/composer'] = $this->projectPath().'/composer.json'; |
| 135 | 135 | $this->touch['test/index'] = $this->storage().'/index.html'; |
| 136 | - $this->touch['exception/authenticate'] = $this->directory['exceptionDir'] .'/AuthenticateException.php'; |
|
| 136 | + $this->touch['exception/authenticate'] = $this->directory['exceptionDir'].'/AuthenticateException.php'; |
|
| 137 | 137 | |
| 138 | 138 | //set project touch |
| 139 | 139 | $this->file->touch($this); |
@@ -31,14 +31,14 @@ discard block |
||
| 31 | 31 | * @param string $method |
| 32 | 32 | * @param bool $break |
| 33 | 33 | */ |
| 34 | - private function allWorkers($method='start',$break=false) |
|
| 34 | + private function allWorkers($method = 'start', $break = false) |
|
| 35 | 35 | {
|
| 36 | - foreach(app()->get('worker') as $key=>$item){
|
|
| 36 | + foreach (app()->get('worker') as $key=>$item) {
|
|
| 37 | 37 | $this->argument['worker'] = ucfirst($key); |
| 38 | 38 | $this->argument[$key] = ucfirst($key); |
| 39 | 39 | $this->{$method}();
|
| 40 | 40 | |
| 41 | - if($break) break; |
|
| 41 | + if ($break) break; |
|
| 42 | 42 | } |
| 43 | 43 | exit(); |
| 44 | 44 | } |
@@ -48,22 +48,22 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | public function start() |
| 50 | 50 | {
|
| 51 | - if(is_null($this->argument['worker'])){
|
|
| 51 | + if (is_null($this->argument['worker'])) {
|
|
| 52 | 52 | $this->allWorkers(); |
| 53 | 53 | exit(); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | $workerName = $this->projectName().'-'.$this->argument['worker']; |
| 57 | 57 | app()->terminate('WORKER');
|
| 58 | - app()->register('WORKER',$workerName);
|
|
| 58 | + app()->register('WORKER', $workerName);
|
|
| 59 | 59 | app()->terminate('PROJECT_NAME');
|
| 60 | - app()->register('PROJECT_NAME',strtolower($this->projectName()));
|
|
| 61 | - app()->register('WORKER_START',true);
|
|
| 62 | - app()->register('WORKER_STOP',false);
|
|
| 63 | - app()->register('WORKER_STATUS',false);
|
|
| 64 | - app()->register('WORKER_CLEAR',false);
|
|
| 60 | + app()->register('PROJECT_NAME', strtolower($this->projectName()));
|
|
| 61 | + app()->register('WORKER_START', true);
|
|
| 62 | + app()->register('WORKER_STOP', false);
|
|
| 63 | + app()->register('WORKER_STATUS', false);
|
|
| 64 | + app()->register('WORKER_CLEAR', false);
|
|
| 65 | 65 | |
| 66 | - app()->resolve(WorkerManager::class,['args'=>$this->argument])->execute(); |
|
| 66 | + app()->resolve(WorkerManager::class, ['args'=>$this->argument])->execute(); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -71,22 +71,22 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | public function stop() |
| 73 | 73 | {
|
| 74 | - if(is_null($this->argument['worker'])){
|
|
| 74 | + if (is_null($this->argument['worker'])) {
|
|
| 75 | 75 | $this->allWorkers('stop');
|
| 76 | 76 | exit(); |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | $workerName = $this->projectName().'-'.$this->argument['worker']; |
| 80 | 80 | app()->terminate('WORKER');
|
| 81 | - app()->register('WORKER',$workerName);
|
|
| 81 | + app()->register('WORKER', $workerName);
|
|
| 82 | 82 | app()->terminate('PROJECT_NAME');
|
| 83 | - app()->register('PROJECT_NAME',strtolower($this->projectName()));
|
|
| 84 | - app()->register('WORKER_START',false);
|
|
| 85 | - app()->register('WORKER_STOP',true);
|
|
| 86 | - app()->register('WORKER_STATUS',false);
|
|
| 87 | - app()->register('WORKER_CLEAR',false);
|
|
| 83 | + app()->register('PROJECT_NAME', strtolower($this->projectName()));
|
|
| 84 | + app()->register('WORKER_START', false);
|
|
| 85 | + app()->register('WORKER_STOP', true);
|
|
| 86 | + app()->register('WORKER_STATUS', false);
|
|
| 87 | + app()->register('WORKER_CLEAR', false);
|
|
| 88 | 88 | |
| 89 | - app()->resolve(WorkerManager::class,['args'=>$this->argument])->execute(); |
|
| 89 | + app()->resolve(WorkerManager::class, ['args'=>$this->argument])->execute(); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /** |
@@ -94,20 +94,20 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | public function status() |
| 96 | 96 | {
|
| 97 | - if(is_null($this->argument['worker'])){
|
|
| 98 | - $this->allWorkers('status',true);
|
|
| 97 | + if (is_null($this->argument['worker'])) {
|
|
| 98 | + $this->allWorkers('status', true);
|
|
| 99 | 99 | exit(); |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | $workerName = $this->projectName().'-'.$this->argument['worker']; |
| 103 | - app()->register('WORKER',$workerName);
|
|
| 104 | - app()->register('PROJECT_NAME',strtolower($this->projectName()));
|
|
| 105 | - app()->register('WORKER_START',false);
|
|
| 106 | - app()->register('WORKER_STOP',false);
|
|
| 107 | - app()->register('WORKER_STATUS',true);
|
|
| 108 | - app()->register('WORKER_CLEAR',false);
|
|
| 109 | - |
|
| 110 | - app()->resolve(WorkerManager::class,['args'=>$this->argument])->execute(); |
|
| 103 | + app()->register('WORKER', $workerName);
|
|
| 104 | + app()->register('PROJECT_NAME', strtolower($this->projectName()));
|
|
| 105 | + app()->register('WORKER_START', false);
|
|
| 106 | + app()->register('WORKER_STOP', false);
|
|
| 107 | + app()->register('WORKER_STATUS', true);
|
|
| 108 | + app()->register('WORKER_CLEAR', false);
|
|
| 109 | + |
|
| 110 | + app()->resolve(WorkerManager::class, ['args'=>$this->argument])->execute(); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | /** |
@@ -115,22 +115,22 @@ discard block |
||
| 115 | 115 | */ |
| 116 | 116 | public function clear() |
| 117 | 117 | {
|
| 118 | - if(is_null($this->argument['worker'])){
|
|
| 118 | + if (is_null($this->argument['worker'])) {
|
|
| 119 | 119 | $this->allWorkers('clear');
|
| 120 | 120 | exit(); |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | $workerName = $this->projectName().'-'.$this->argument['worker']; |
| 124 | 124 | app()->terminate('WORKER');
|
| 125 | - app()->register('WORKER',$workerName);
|
|
| 125 | + app()->register('WORKER', $workerName);
|
|
| 126 | 126 | app()->terminate('PROJECT_NAME');
|
| 127 | - app()->register('PROJECT_NAME',strtolower($this->projectName()));
|
|
| 128 | - app()->register('WORKER_START',false);
|
|
| 129 | - app()->register('WORKER_STOP',false);
|
|
| 130 | - app()->register('WORKER_STATUS',false);
|
|
| 131 | - app()->register('WORKER_CLEAR',true);
|
|
| 127 | + app()->register('PROJECT_NAME', strtolower($this->projectName()));
|
|
| 128 | + app()->register('WORKER_START', false);
|
|
| 129 | + app()->register('WORKER_STOP', false);
|
|
| 130 | + app()->register('WORKER_STATUS', false);
|
|
| 131 | + app()->register('WORKER_CLEAR', true);
|
|
| 132 | 132 | |
| 133 | - app()->resolve(WorkerManager::class,['args'=>$this->argument])->execute(); |
|
| 133 | + app()->resolve(WorkerManager::class, ['args'=>$this->argument])->execute(); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /** |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | public function create() |
| 140 | 140 | {
|
| 141 | - if(!file_exists(app()->path()->workers())){
|
|
| 141 | + if (!file_exists(app()->path()->workers())) {
|
|
| 142 | 142 | $this->directory['worker'] = app()->path()->workers(); |
| 143 | 143 | $this->file->makeDirectory($this); |
| 144 | 144 | } |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | $this->argument['workerClass'] = ucfirst($this->argument['worker']).''; |
| 148 | 148 | $this->argument['projectName'] = strtolower($this->projectName()); |
| 149 | 149 | |
| 150 | - $this->touch['worker/worker']= app()->path()->workers().'/'.$this->argument['worker'].'.php'; |
|
| 150 | + $this->touch['worker/worker'] = app()->path()->workers().'/'.$this->argument['worker'].'.php'; |
|
| 151 | 151 | |
| 152 | 152 | |
| 153 | 153 | $this->file->touch($this); |
@@ -38,7 +38,9 @@ |
||
| 38 | 38 | $this->argument[$key] = ucfirst($key); |
| 39 | 39 | $this->{$method}();
|
| 40 | 40 | |
| 41 | - if($break) break; |
|
| 41 | + if($break) {
|
|
| 42 | + break; |
|
| 43 | + } |
|
| 42 | 44 | } |
| 43 | 45 | exit(); |
| 44 | 46 | } |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | * @param ApplicationContracts $app |
| 26 | 26 | * @param WorkerManagerContracts $worker |
| 27 | 27 | */ |
| 28 | - public function __construct(ApplicationContracts $app,WorkerManagerContracts $worker) |
|
| 28 | + public function __construct(ApplicationContracts $app, WorkerManagerContracts $worker) |
|
| 29 | 29 | { |
| 30 | 30 | parent::__construct($app); |
| 31 | 31 | |
@@ -41,19 +41,19 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | public function jobProcessor() |
| 43 | 43 | { |
| 44 | - if($this->app->get('WORKER_START')===true){ |
|
| 44 | + if ($this->app->get('WORKER_START')===true) { |
|
| 45 | 45 | return 'start'; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - if($this->app->get('WORKER_STOP')===true){ |
|
| 48 | + if ($this->app->get('WORKER_STOP')===true) { |
|
| 49 | 49 | return 'stop'; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - if($this->app->get('WORKER_STATUS')===true){ |
|
| 52 | + if ($this->app->get('WORKER_STATUS')===true) { |
|
| 53 | 53 | return 'status'; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - if($this->app->get('WORKER_CLEAR')===true){ |
|
| 56 | + if ($this->app->get('WORKER_CLEAR')===true) { |
|
| 57 | 57 | return 'clear'; |
| 58 | 58 | } |
| 59 | 59 | } |
@@ -13,9 +13,9 @@ |
||
| 13 | 13 | * @param null|string $command |
| 14 | 14 | * @return mixed|void |
| 15 | 15 | */ |
| 16 | - public function command($command=null) |
|
| 16 | + public function command($command = null) |
|
| 17 | 17 | { |
| 18 | - $process = new ProcessHandler($command,root.''); |
|
| 18 | + $process = new ProcessHandler($command, root.''); |
|
| 19 | 19 | $process->run(); |
| 20 | 20 | |
| 21 | 21 | // executes after the command finishes |
@@ -85,15 +85,15 @@ discard block |
||
| 85 | 85 | { |
| 86 | 86 | $list = []; |
| 87 | 87 | |
| 88 | - $status = array_filter(explode("\n",$this->process->command(config('supervisor.commands.workers'))),'strlen'); |
|
| 88 | + $status = array_filter(explode("\n", $this->process->command(config('supervisor.commands.workers'))), 'strlen'); |
|
| 89 | 89 | |
| 90 | - foreach ($status as $item){ |
|
| 91 | - if(preg_match('@'.$this->app->get('PROJECT_NAME').'.*@is',$item,$array)){ |
|
| 90 | + foreach ($status as $item) { |
|
| 91 | + if (preg_match('@'.$this->app->get('PROJECT_NAME').'.*@is', $item, $array)) { |
|
| 92 | 92 | $list[] = $item; |
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - return implode(PHP_EOL,$list).''.PHP_EOL; |
|
| 96 | + return implode(PHP_EOL, $list).''.PHP_EOL; |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | /** |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | { |
| 106 | 106 | $supervisorStatus = $this->process->command(config('supervisor.commands.status')); |
| 107 | 107 | |
| 108 | - if(false===$supervisorStatus){ |
|
| 108 | + if (false===$supervisorStatus) { |
|
| 109 | 109 | $this->upSupervisor(); |
| 110 | 110 | } |
| 111 | 111 | return $this->process->command(config('supervisor.commands.status')); |
@@ -160,8 +160,8 @@ discard block |
||
| 160 | 160 | { |
| 161 | 161 | $path = config('supervisor.path').'/'.$this->app->get('WORKER').'.conf'; |
| 162 | 162 | |
| 163 | - if(files()->exists($path)===false){ |
|
| 164 | - files()->put($path,' |
|
| 163 | + if (files()->exists($path)===false) { |
|
| 164 | + files()->put($path, ' |
|
| 165 | 165 | [group:'.$this->app->get('PROJECT_NAME').'] |
| 166 | 166 | [program:'.$this->app()->get('WORKER').'] |
| 167 | 167 | process_name=%(program_name)s_%(process_num)02d |