yii-starter-kit / yii2-starter-kit

Yii2 Starter Kit
http://yii2-starter-kit.terentev.net
Other
1.42k stars 648 forks source link

Maintenance Mode not working (?#72) #171

Closed dbd5 closed 9 years ago

dbd5 commented 9 years ago

Hello,

Sorry I couldn't read #72 so I'm not sure if this has been dealt with.

I assume enabling frontend maintenance mode will display a message on frontend that says "Website is under maintenance" and subsequently deny both login and signup access. However this is not happening. Is this the expected behavior?

Regards,

Adam

trntv commented 9 years ago

note that maintenance behavior attaches only on prod environment

dbd5 commented 9 years ago

Thanks Eugene! However, I suggest you look at this again and consider attaching to both prod and dev for the simple reason that all application features should be testable in dev. Once you upload to a real prod environment in use by a business, you will need change management approval to take down a production resource like a business website.

trntv commented 9 years ago

If to be honest it is disabled in dev environment because of debug toolbar :-) It looks ugly. If you'll find a way to handle this issue, i'll change config

dbd5 commented 9 years ago

Happy to look into this!

But I first have to see the ugliness you speak of to understand the problem. I tried changing YII_ENV_DEV to YII_ENV_PROD in frontend/config/web.php and changing the 'true' to 1 in the return statement since the value stored for 'frontend.maintenance' in Key-Value storage is either 1 or 0. It still didn't work.

How do I enable it in DEV?

trntv commented 9 years ago

Just remove this condition: https://github.com/trntv/yii2-starter-kit/blob/master/frontend/config/web.php#L56

2015-05-25 11:51 GMT+03:00 dbd5 notifications@github.com:

Happy to look into this!

But I first have to see the ugliness you speak of to understand the problem. I tried changing YII_ENV_DEV to YII_ENV_PROD in frontend/config/web.php and changing the 'true' to 1 in the return statement since the value stored for 'frontend.maintenance' in Key-Value storage is either 1 or 0. It still didn't work.

How do I enable it in DEV?

— Reply to this email directly or view it on GitHub https://github.com/trntv/yii2-starter-kit/issues/171#issuecomment-105170930 .

dbd5 commented 9 years ago

I did, still didn't work - user conrad was still able to logon at the frontend. See screenshots below;

screen shot 2015-05-25 at 10 24 27 am

screen shot 2015-05-25 at 10 23 53 am

screen shot 2015-05-25 at 10 23 29 am

trntv commented 9 years ago

oh...

//if (YII_ENV_PROD) {
    $config['bootstrap'] = ['maintenance'];
    $config['components']['maintenance'] = [
        'class' => 'common\components\maintenance\Maintenance',
        'enabled' => function ($app) {
            return $app->keyStorage->get('frontend.maintenance') === 'enabled';
        }
    ];
//}
dbd5 commented 9 years ago

I made the change and refreshed but frontend user is still able to login

trntv commented 9 years ago

Did you see this? https://github.com/trntv/yii2-starter-kit/commit/2fd57e37945515af53a54b97b97eb7ad7d6eff1c

dbd5 commented 9 years ago

It appears we're dealing with an additional problem here:

Selecting 'Disabled' from the control panel saves 'disabled' to the database but selecting 'Enabled' saves 0 to the database which may be why the maintenance mode fails to display in the frontend (the logic expects 'enabled' but sees 0).

However, I got the maintenance mode to show on the front panel by typing 'enabled' manually to the database.

Now back to the original issue;

"If to be honest it is disabled in dev environment because of debug toolbar :-) It looks ugly. If you'll find a way to handle this issue, i'll change config"

The debug panel didn't appear at all even though it is configured, and yes the maintenance mode screen is a bit bland. Which do you want me to handle, debug not showing up or the ugly look as you call it?

Regards,

Adam