@@ -31,11 +31,11 @@ discard block |
||
| 31 | 31 | public function run() |
| 32 | 32 | {
|
| 33 | 33 | $workerName = $this->projectName().'-'.$this->argument['worker']; |
| 34 | - app()->register('WORKER',$workerName);
|
|
| 35 | - app()->register('PROJECT_NAME',strtolower($this->projectName()));
|
|
| 36 | - app()->register('WORKER_STATUS',false);
|
|
| 34 | + app()->register('WORKER', $workerName);
|
|
| 35 | + app()->register('PROJECT_NAME', strtolower($this->projectName()));
|
|
| 36 | + app()->register('WORKER_STATUS', false);
|
|
| 37 | 37 | |
| 38 | - app()->resolve(WorkerManager::class,['args'=>$this->argument])->execute(); |
|
| 38 | + app()->resolve(WorkerManager::class, ['args'=>$this->argument])->execute(); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -44,11 +44,11 @@ discard block |
||
| 44 | 44 | public function stop() |
| 45 | 45 | {
|
| 46 | 46 | $workerName = $this->projectName().'-'.$this->argument['worker']; |
| 47 | - app()->register('WORKER',$workerName);
|
|
| 48 | - app()->register('PROJECT_NAME',strtolower($this->projectName()));
|
|
| 49 | - app()->register('WORKER_STATUS',true);
|
|
| 47 | + app()->register('WORKER', $workerName);
|
|
| 48 | + app()->register('PROJECT_NAME', strtolower($this->projectName()));
|
|
| 49 | + app()->register('WORKER_STATUS', true);
|
|
| 50 | 50 | |
| 51 | - app()->resolve(WorkerManager::class,['args'=>$this->argument])->execute(); |
|
| 51 | + app()->resolve(WorkerManager::class, ['args'=>$this->argument])->execute(); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | public function create() |
| 58 | 58 | {
|
| 59 | - if(!file_exists(app()->path()->workers())){
|
|
| 59 | + if (!file_exists(app()->path()->workers())) {
|
|
| 60 | 60 | $this->directory['worker'] = app()->path()->workers(); |
| 61 | 61 | $this->file->makeDirectory($this); |
| 62 | 62 | } |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | $this->argument['workerClass'] = ucfirst($this->argument['worker']).''; |
| 66 | 66 | $this->argument['projectName'] = strtolower($this->projectName()); |
| 67 | 67 | |
| 68 | - $this->touch['worker/worker']= app()->path()->workers().'/'.$this->argument['worker'].'.php'; |
|
| 68 | + $this->touch['worker/worker'] = app()->path()->workers().'/'.$this->argument['worker'].'.php'; |
|
| 69 | 69 | |
| 70 | 70 | |
| 71 | 71 | $this->file->touch($this); |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | * @param ApplicationContracts $app |
| 27 | 27 | * @param WorkerManagerContracts $worker |
| 28 | 28 | */ |
| 29 | - public function __construct(ApplicationContracts $app,WorkerManagerContracts $worker) |
|
| 29 | + public function __construct(ApplicationContracts $app, WorkerManagerContracts $worker) |
|
| 30 | 30 | { |
| 31 | 31 | parent::__construct($app); |
| 32 | 32 | |
@@ -44,11 +44,11 @@ discard block |
||
| 44 | 44 | { |
| 45 | 45 | $this->isSupervisorRunning(); |
| 46 | 46 | |
| 47 | - if($this->app->get('WORKER_STATUS')===true){ |
|
| 47 | + if ($this->app->get('WORKER_STATUS')===true) { |
|
| 48 | 48 | |
| 49 | 49 | $this->stopWorkerForSupervisor(); |
| 50 | 50 | } |
| 51 | - else{ |
|
| 51 | + else { |
|
| 52 | 52 | |
| 53 | 53 | $this->putConfigurationFile(); |
| 54 | 54 | |
@@ -121,8 +121,8 @@ discard block |
||
| 121 | 121 | { |
| 122 | 122 | $path = config('supervisor.path').'/'.$this->app->get('WORKER').'.conf'; |
| 123 | 123 | |
| 124 | - if(files()->exists($path)===false){ |
|
| 125 | - files()->put($path,' |
|
| 124 | + if (files()->exists($path)===false) { |
|
| 125 | + files()->put($path, ' |
|
| 126 | 126 | [program:'.$this->app()->get('WORKER').'] |
| 127 | 127 | process_name=%(program_name)s_%(process_num)02d |
| 128 | 128 | command=php '.root.'/api worker run '.$this->app->get('PROJECT_NAME').' worker:'.$this->worker->getWorker().' |
@@ -47,8 +47,7 @@ |
||
| 47 | 47 | if($this->app->get('WORKER_STATUS')===true){ |
| 48 | 48 | |
| 49 | 49 | $this->stopWorkerForSupervisor(); |
| 50 | - } |
|
| 51 | - else{ |
|
| 50 | + } else{ |
|
| 52 | 51 | |
| 53 | 52 | $this->putConfigurationFile(); |
| 54 | 53 | |
@@ -132,7 +132,7 @@ |
||
| 132 | 132 | public function __call($name, $arguments) |
| 133 | 133 | { |
| 134 | 134 | $job = $this->app->get('macro')->call($this->getApply().'Worker',function() use($name){ |
| 135 | - return __NAMESPACE__.'\\'.ucfirst($name).'Job'; |
|
| 135 | + return __NAMESPACE__.'\\'.ucfirst($name).'Job'; |
|
| 136 | 136 | }); |
| 137 | 137 | |
| 138 | 138 | if(Utils::isNamespaceExists($job)){ |
@@ -24,15 +24,15 @@ discard block |
||
| 24 | 24 | * @param ApplicationContracts $app |
| 25 | 25 | * @param array $args |
| 26 | 26 | */ |
| 27 | - public function __construct(ApplicationContracts $app, $args=array()) |
|
| 27 | + public function __construct(ApplicationContracts $app, $args = array()) |
|
| 28 | 28 | { |
| 29 | 29 | parent::__construct($app); |
| 30 | 30 | |
| 31 | - if($this->app->runningInConsole()===false){ |
|
| 31 | + if ($this->app->runningInConsole()===false) { |
|
| 32 | 32 | exception()->runtime('The worker can only be run as cli..'); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - if($this->app->has('WORKER')===false){ |
|
| 35 | + if ($this->app->has('WORKER')===false) { |
|
| 36 | 36 | exception()->runtime('The worker console manipulation for WORKER container value'); |
| 37 | 37 | } |
| 38 | 38 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | public function getApply() |
| 50 | 50 | { |
| 51 | - if(isset($this->args['apply'])){ |
|
| 51 | + if (isset($this->args['apply'])) { |
|
| 52 | 52 | return $this->args['apply']; |
| 53 | 53 | } |
| 54 | 54 | |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public function getData() |
| 64 | 64 | { |
| 65 | - if(isset($this->args['data'])){ |
|
| 65 | + if (isset($this->args['data'])) { |
|
| 66 | 66 | return $this->args['data']; |
| 67 | 67 | } |
| 68 | 68 | |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | public function getPauseValue() |
| 78 | 78 | { |
| 79 | - if(isset($this->args['pause'])){ |
|
| 79 | + if (isset($this->args['pause'])) { |
|
| 80 | 80 | return $this->args['pause']; |
| 81 | 81 | } |
| 82 | 82 | |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | public function getWorker() |
| 92 | 92 | { |
| 93 | - if(isset($this->args['worker'],$this->worker[$worker = strtolower($this->args['worker'])])){ |
|
| 93 | + if (isset($this->args['worker'], $this->worker[$worker = strtolower($this->args['worker'])])) { |
|
| 94 | 94 | return $worker; |
| 95 | 95 | } |
| 96 | 96 | |
@@ -112,12 +112,12 @@ discard block |
||
| 112 | 112 | * |
| 113 | 113 | * @param null|\int $pause |
| 114 | 114 | */ |
| 115 | - public function pause($pause=null) |
|
| 115 | + public function pause($pause = null) |
|
| 116 | 116 | { |
| 117 | - if(is_null($pause)){ |
|
| 117 | + if (is_null($pause)) { |
|
| 118 | 118 | sleep($this->getPauseValue()); |
| 119 | 119 | } |
| 120 | - else{ |
|
| 120 | + else { |
|
| 121 | 121 | sleep($pause); |
| 122 | 122 | } |
| 123 | 123 | } |
@@ -131,12 +131,12 @@ discard block |
||
| 131 | 131 | */ |
| 132 | 132 | public function __call($name, $arguments) |
| 133 | 133 | { |
| 134 | - $job = $this->app->get('macro')->call($this->getApply().'Worker',function() use($name){ |
|
| 134 | + $job = $this->app->get('macro')->call($this->getApply().'Worker', function() use($name){ |
|
| 135 | 135 | return __NAMESPACE__.'\\'.ucfirst($name).'Job'; |
| 136 | 136 | }); |
| 137 | 137 | |
| 138 | - if(Utils::isNamespaceExists($job)){ |
|
| 139 | - return $this->app->resolve($job,['worker'=>$this])->execute(); |
|
| 138 | + if (Utils::isNamespaceExists($job)) { |
|
| 139 | + return $this->app->resolve($job, ['worker'=>$this])->execute(); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | exception()->runtime('Job Class not found'); |