| @@ 36-61 (lines=26) @@ | ||
| 33 | * |
|
| 34 | * @return int |
|
| 35 | */ |
|
| 36 | public function handle() |
|
| 37 | { |
|
| 38 | $part = Str::slug($this->argument('part')); |
|
| 39 | ||
| 40 | $lockFilename = 'framework/partial-down-'.$part; |
|
| 41 | ||
| 42 | try { |
|
| 43 | if (file_exists(storage_path($lockFilename))) { |
|
| 44 | $this->comment("This part [{$part}] of the application is already down."); |
|
| 45 | ||
| 46 | return true; |
|
| 47 | } |
|
| 48 | ||
| 49 | file_put_contents(storage_path($lockFilename), |
|
| 50 | json_encode($this->getDownFilePayload(), |
|
| 51 | JSON_PRETTY_PRINT)); |
|
| 52 | ||
| 53 | $this->comment("This part [{$part}] of the application is now in maintenance mode."); |
|
| 54 | } catch (Exception $e) { |
|
| 55 | $this->error("Failed to put this part [{$part}] of the application in maintenance mode."); |
|
| 56 | ||
| 57 | $this->error($e->getMessage()); |
|
| 58 | ||
| 59 | return 1; |
|
| 60 | } |
|
| 61 | } |
|
| 62 | ||
| 63 | /** |
|
| 64 | * Get the payload to be placed in the "down" file. |
|
| @@ 30-53 (lines=24) @@ | ||
| 27 | * |
|
| 28 | * @return int |
|
| 29 | */ |
|
| 30 | public function handle() |
|
| 31 | { |
|
| 32 | $part = Str::slug($this->argument('part')); |
|
| 33 | ||
| 34 | $lockFilename = 'framework/partial-down-'.$part; |
|
| 35 | ||
| 36 | try { |
|
| 37 | if (! file_exists(storage_path($lockFilename))) { |
|
| 38 | $this->comment("This part [{$part}] of the application is already up."); |
|
| 39 | ||
| 40 | return true; |
|
| 41 | } |
|
| 42 | ||
| 43 | unlink(storage_path($lockFilename)); |
|
| 44 | ||
| 45 | $this->info("This part [{$part}] of the application is now live."); |
|
| 46 | } catch (Exception $e) { |
|
| 47 | $this->error("Failed to disable maintenance mode for this part [{$part}] of the application."); |
|
| 48 | ||
| 49 | $this->error($e->getMessage()); |
|
| 50 | ||
| 51 | return 1; |
|
| 52 | } |
|
| 53 | } |
|
| 54 | } |
|
| 55 | ||