@@ -34,11 +34,11 @@ discard block |
||
| 34 | 34 | /** |
| 35 | 35 | * @return void |
| 36 | 36 | */ |
| 37 | - public function create(){
|
|
| 37 | + public function create() {
|
|
| 38 | 38 | |
| 39 | 39 | $schedulePath = app()->path()->schedule(); |
| 40 | 40 | |
| 41 | - if(!file_exists($schedulePath)){
|
|
| 41 | + if (!file_exists($schedulePath)) {
|
|
| 42 | 42 | $this->directory['schedule'] = $schedulePath; |
| 43 | 43 | $this->file->makeDirectory($this); |
| 44 | 44 | } |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | $this->argument['scheduleClass'] = ucfirst($this->argument['schedule']).''; |
| 48 | 48 | $this->argument['projectName'] = strtolower($this->projectName()); |
| 49 | 49 | |
| 50 | - $this->touch['schedule/schedule']= $schedulePath.'/'.$this->argument['schedule'].'.php'; |
|
| 50 | + $this->touch['schedule/schedule'] = $schedulePath.'/'.$this->argument['schedule'].'.php'; |
|
| 51 | 51 | |
| 52 | 52 | |
| 53 | 53 | $this->file->touch($this); |
@@ -57,30 +57,30 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | public function list() |
| 59 | 59 | {
|
| 60 | - exec('crontab -l',$list);
|
|
| 60 | + exec('crontab -l', $list);
|
|
| 61 | 61 | |
| 62 | - $this->table->setHeaders(['no','minute','hour','day','month','week','schedule','description']); |
|
| 62 | + $this->table->setHeaders(['no', 'minute', 'hour', 'day', 'month', 'week', 'schedule', 'description']); |
|
| 63 | 63 | |
| 64 | 64 | |
| 65 | - foreach ($list as $key=>$item){
|
|
| 65 | + foreach ($list as $key=>$item) {
|
|
| 66 | 66 | |
| 67 | - if(preg_match('@.*php api schedule run '.strtolower($this->projectName()).'.*@is',$item,$result)){
|
|
| 68 | - if(isset($result[0])){
|
|
| 67 | + if (preg_match('@.*php api schedule run '.strtolower($this->projectName()).'.*@is', $item, $result)) {
|
|
| 68 | + if (isset($result[0])) {
|
|
| 69 | 69 | |
| 70 | 70 | $cron = []; |
| 71 | 71 | |
| 72 | - if(preg_match('@(.*)\scd@',$result[0],$cron)){
|
|
| 73 | - $cron = (isset($cron[1])) ? explode(' ',$cron[1]) : '';
|
|
| 72 | + if (preg_match('@(.*)\scd@', $result[0], $cron)) {
|
|
| 73 | + $cron = (isset($cron[1])) ? explode(' ', $cron[1]) : '';
|
|
| 74 | 74 | |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | $scheduleName = ''; |
| 78 | 78 | |
| 79 | - if(preg_match('@schedule\:(.*?)\s@',$result[0],$scheduler)){
|
|
| 79 | + if (preg_match('@schedule\:(.*?)\s@', $result[0], $scheduler)) {
|
|
| 80 | 80 | $scheduleName = (isset($scheduler[1])) ? $scheduler[1] : ''; |
| 81 | 81 | |
| 82 | 82 | $schedulerInstance = $this->scheduleInstance(ucfirst($scheduleName)); |
| 83 | - $description = ClosureDispatcher::bind($schedulerInstance)->call(function(){
|
|
| 83 | + $description = ClosureDispatcher::bind($schedulerInstance)->call(function() {
|
|
| 84 | 84 | return $this->description; |
| 85 | 85 | }); |
| 86 | 86 | |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | $schedules = Utils::glob(app()->path()->schedule()); |
| 112 | 112 | |
| 113 | 113 | |
| 114 | - if(isset($schedules[$this->argument['schedule']])){
|
|
| 114 | + if (isset($schedules[$this->argument['schedule']])) {
|
|
| 115 | 115 | |
| 116 | 116 | $scheduleNamespace = Utils::getNamespace($schedules[$this->argument['schedule']]); |
| 117 | 117 | $scheduleInstance = app()->resolve($scheduleNamespace); |
@@ -119,11 +119,11 @@ discard block |
||
| 119 | 119 | $scheduleManager = new ScheduleManager(); |
| 120 | 120 | $scheduleInstance->when($scheduleManager); |
| 121 | 121 | |
| 122 | - $cronScheduler = implode(' ',$scheduleManager->getCronScheduler());
|
|
| 122 | + $cronScheduler = implode(' ', $scheduleManager->getCronScheduler());
|
|
| 123 | 123 | |
| 124 | 124 | $command = $cronScheduler.' cd '.root.' && php api schedule run munch schedule:'.lcfirst($this->argument['schedule']).' >> /dev/null 2>&1'; |
| 125 | 125 | |
| 126 | - if($this->cronjob_exists($command)===false){
|
|
| 126 | + if ($this->cronjob_exists($command)===false) {
|
|
| 127 | 127 | |
| 128 | 128 | $output = shell_exec('crontab -l');
|
| 129 | 129 | file_put_contents('/tmp/crontab.txt', $output.''.$command.''.PHP_EOL);
|
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | {
|
| 142 | 142 | $schedules = Utils::glob(app()->path()->schedule()); |
| 143 | 143 | |
| 144 | - if(isset($schedules[$this->argument['schedule']])){
|
|
| 144 | + if (isset($schedules[$this->argument['schedule']])) {
|
|
| 145 | 145 | $scheduleNamespace = Utils::getNamespace($schedules[$this->argument['schedule']]); |
| 146 | 146 | $scheduleInstance = app()->resolve($scheduleNamespace); |
| 147 | 147 | |
@@ -149,20 +149,20 @@ discard block |
||
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - private function cronjob_exists($command){
|
|
| 152 | + private function cronjob_exists($command) {
|
|
| 153 | 153 | |
| 154 | - $cronjob_exists=false; |
|
| 154 | + $cronjob_exists = false; |
|
| 155 | 155 | |
| 156 | 156 | exec('crontab -l', $crontab);
|
| 157 | 157 | |
| 158 | 158 | |
| 159 | - if(isset($crontab)&&is_array($crontab)){
|
|
| 159 | + if (isset($crontab) && is_array($crontab)) {
|
|
| 160 | 160 | |
| 161 | 161 | $crontab = array_flip($crontab); |
| 162 | 162 | |
| 163 | - if(isset($crontab[$command])){
|
|
| 163 | + if (isset($crontab[$command])) {
|
|
| 164 | 164 | |
| 165 | - $cronjob_exists=true; |
|
| 165 | + $cronjob_exists = true; |
|
| 166 | 166 | |
| 167 | 167 | } |
| 168 | 168 | |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | {
|
| 179 | 179 | $schedules = Utils::glob(app()->path()->schedule()); |
| 180 | 180 | |
| 181 | - if(isset($schedules[$schedule])){
|
|
| 181 | + if (isset($schedules[$schedule])) {
|
|
| 182 | 182 | $scheduleNamespace = Utils::getNamespace($schedules[$schedule]); |
| 183 | 183 | return $scheduleInstance = app()->resolve($scheduleNamespace); |
| 184 | 184 | } |