/** * Execute the console command. * * @return mixed */ public function fire() { // Check not 'sync' if (Config::get('queue.default') == "sync") { Artisan::call('down'); $this->info("Application maintenance mode enabled."); return; } // Push job onto queue Queue::push(function ($job) { // Take Application down. Artisan::call('down'); // Add Log message Log::info("Application is down, pausing queue while maintenance happens."); // Loop, waiting for app to come back up while (App::isDownForMaintenance()) { echo "."; sleep(5); } // App is back online, kill worker to restart daemon. Log::info("Application is up, rebooting queue."); Artisan::call('queue:restart'); $job->delete(); }); // Wait until Maintenance Mode enabled. while (!App::isDownForMaintenance()) { sleep(1); } $this->info("Application maintenance mode enabled."); }
/** * Execute the console command. * * @return mixed */ public function handle() { if (!$this->verifyInstalled() || $this->hasRunningDeployments() || $this->composerOutdated() || $this->nodeOutdated() || !$this->checkRequirements()) { return -1; } $bring_back_up = false; if (!App::isDownForMaintenance()) { $this->error(Lang::get('app.not_down')); if (!$this->confirm(Lang::get('app.switch_down'))) { return; } $bring_back_up = true; $this->call('down'); } $this->backupDatabase(); $this->updateConfiguration(); $this->clearCaches(); $this->migrate(); $this->optimize(); $this->restartQueue(); $this->restartSocket(); // If we prompted the user to bring the app down, bring it back up if ($bring_back_up) { $this->call('up'); } }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @return mixed */ public function handle(Request $request, Closure $next) { if (App::isDownForMaintenance()) { throw new HttpException(503); } return $next($request); }
/** * Execute the console command. */ public function handle() { $bring_back_up = false; // Check the app is offline, if not ask the user if it can be brought down if (!App::isDownForMaintenance()) { $this->error(Lang::get('app.not_down')); if (!$this->confirm(Lang::get('app.switch_down'))) { return; } $bring_back_up = true; $this->call('down'); } $this->cleanupDeployments(); // If we prompted the user to bring the app down, bring it back up if ($bring_back_up) { $this->call('up'); } }