Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm just wondering if anyone know's if there's a way to activate maintenance mode on a laravel website without using Artisan? I don't have command line access to the server so I can't use Artisan without first updating it on my local site and then push the changes to the server. Is there maybe a master Route that I can add that will deny access to any other routes?

Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
903 views
Welcome To Ask or Share your Answers For Others

1 Answer

You can just call artisan from your application:

Artisan::call('down');

Artisan::call('up');

But since you'll not have access to get your app up because it's down. You can create the functionality yourself:

A route for shut it down, user must be authenticated to do this:

Route::group(array('before' => 'auth'), function()
{

    Route::get('shut/the/application/down', function() 
    {
        touch(storage_path().'/meta/my.down');
    });

});

A route to bring it back up:

Route::get('bring/the/application/back/up', function() 
{
    @unlink(storage_path().'/meta/my.down');
});

A filter to check if it's up:

Route::filter('applicationIsUp', function()
{
    if (file_exists($this['path.storage'].'/meta/my.down'))
    {
        return Redirect::to('site/is/down');
    }
});

A route to bring it back up:

Route::get('bring/the/application/back/up', function() 
{
    @unlink(storage_path().'/meta/my.down');
});

A route to show a pretty view when your site is down

Route::get('site/is/down', function() 
{
    return View::make('views.site.down');
});

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...