I want to upload and make some changes on my website, so by calling the below code, I tried to down the laravel server: Web.php:
Route::get('/shotdown_website', function () {
Artisan::call('down');
return "Website Down successfully";
});
Unfortunately, I couldn't get up the server again.
Route::get('/Turn_Up_Desk2929', function () {
Artisan::call('up');
return "Website Up successfully";
});
when I write mywebsite/Turn_Up_Desk2929
in the browser address bar, it redirects me to the error server page which is 503.
Overall, in the first step, I downed the server but in the second part, I could not up the server again. Additionally, in the PHPstorm terminal, I had not any issues. Thanks.
CodePudding user response:
that's because of server is down and you can not make any request even request that make server up.
so if you want to make server up using request then you need to define a secret
when making server down and send the secret with up request
the --secret
can be any string you want:
Route::get('/shotdown_website', function () {
Artisan::call('down',['--secret'=>'630542a-246b']);
return "Website Down successfully";
});
then to access the server as admin you need to send this requet. the secret parameter is token you set in the above code:
https://example.com/secret
in this way a cookie will be created that determine you are admin and can create any request .
so you can call the below route
Route::get('/Turn_Up_Desk2929/', function () {
Artisan::call('up');
return "Website Up successfully";
});
CodePudding user response:
you can run Artisan::call('up')
in a provider files like AppServiceProvider.
this file is renderd in any condition even when application is in maintenance mode . then create any request .
use Illuminate\Support\Facades\Artisan;
class AppServiceProvider extends ServiceProvider
{
public function boot()
{
Artisan::call('up');
//
}
}