Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to go into maintainance mode to safely update a production application, in Symfony 2?

I need to update source files (pull and update from the repository) in my production server, run migrations, and regenerate cached assets.

Is there any mechanism in Symfony 2 to do this safely? Like putting the site into 'maintainance mode' (which should throw a 503) or something?

like image 323
HappyDeveloper Avatar asked Nov 10 '11 20:11

HappyDeveloper


3 Answers

I've just found a Bundle for Symfony 2, which offers you 2 extra-commands in the console to put your application into maintenance mode. Here you go: https://github.com/lexik/LexikMaintenanceBundle

like image 189
Davincho Avatar answered Sep 24 '22 08:09

Davincho


I've been trying to decide how I would implement this. On one hand, Symfony2 provides decent prod caching, so if you're not destructively modifying your database schema (removing columns or tables, etc), you can probably get away with just changing the schema, deploying from your repo, then clearing your prod cache. That's how I handle things most of the time.

On the other hand, if you DO want to go into maintenance mode, you'll want a solution that has minimal load on the framework (ie, you probably don't want to fire up the kernel), or you're defeating the purpose anyway: taking the load off the framework while you muck with things.

If it were me, I'd probably write a simple maintenance script that just sets a 503 header, maybe serves up some static html (pregenerated from my site templates) and sends it back to the user, then use some conditional logic in my app.php to use that when I should be in maintenance mode. It's ugly, but it works.

like image 33
Derek Stobbe Avatar answered Sep 20 '22 08:09

Derek Stobbe


Not sure how to go about this for a bigger site where a user could be in the middle of some kind of transaction (shopping for instance) but for a smaller site could you not just use a .htaccess file (the one in the web directory assuming that is your root) to redirect to some maintenance page instead of into app.php.

like image 37
Kasheen Avatar answered Sep 20 '22 08:09

Kasheen