Skip to content

Commit

Permalink
Merge branch 'error-handling-for-maintenance-mode' of https://github.…
Browse files Browse the repository at this point in the history
…com/match/framework into match-error-handling-for-maintenance-mode
  • Loading branch information
taylorotwell committed Jun 8, 2019
2 parents 7b7eaf9 + 6082be0 commit f849544
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
16 changes: 11 additions & 5 deletions src/Illuminate/Foundation/Console/DownCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Illuminate\Foundation\Console;

use Exception;
use Illuminate\Console\Command;
use Illuminate\Support\InteractsWithTime;

Expand Down Expand Up @@ -32,12 +33,17 @@ class DownCommand extends Command
*/
public function handle()
{
file_put_contents(
storage_path('framework/down'),
json_encode($this->getDownFilePayload(), JSON_PRETTY_PRINT)
);
try {
file_put_contents(storage_path('framework/down'),
json_encode($this->getDownFilePayload(),
JSON_PRETTY_PRINT));
$this->comment('Application is now in maintenance mode.');
} catch (Exception $e) {
$this->error('Application is failed to enter maintenance mode.');
$this->error($e->getMessage());

$this->comment('Application is now in maintenance mode.');
return false;
}
}

/**
Expand Down
16 changes: 14 additions & 2 deletions src/Illuminate/Foundation/Console/UpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Illuminate\Foundation\Console;

use Exception;
use Illuminate\Console\Command;

class UpCommand extends Command
Expand All @@ -27,8 +28,19 @@ class UpCommand extends Command
*/
public function handle()
{
@unlink(storage_path('framework/down'));
try {
if (! file_exists(storage_path('framework/down'))) {
$this->comment('Application is already up.');

$this->info('Application is now live.');
return true;
}
unlink(storage_path('framework/down'));
$this->info('Application is now live.');
} catch (Exception $e) {
$this->error('Application is failed to up.');
$this->error($e->getMessage());

return false;
}
}
}

0 comments on commit f849544

Please sign in to comment.