Once an application gets to the production stage, people get all excited. The project is coming to fruition. Is it all over? No, its just the beginning. Ideally, you want your application to run trouble-free while you sit back and relax.
In this short article I will describe the steps that I go through when setting up a production environment. If you are interested in this subject and want a better guide please refer to deploying rails applications
This will keep everything running, I use this rather than god as it seems more stable and less memory hungry. I have used god a bit; the name also puts me off.
We still run ubuntu not cool enough for CentOS yet so.
Example monit config for rails app server with passenger.
You dont want massive logs slowing your app down after its been running 6 months, remember to configure this as it is often overlooked.
Passenger or mod_rails is in active development and is used by a lot of the big ruby on rails companies and on the big sites. Deployment of production level apps used to be about packs of mongrels and frontend lightweight webservers. No longer.
Deployment with capistrano is standard within the community, with the capistrano-ext gem you can run multistage deployments.
Will deploy to production.
A list of my capistrano bash aliases are as follows. I find them very useful.
alias cpd="cap deploy"
alias cpdm="cap deploy:migrations"
alias cpsd="cap staging deploy"
alias cpsdm="cap staging deploy:migrations"
alias cppd="cap production deploy"
alias cppdm="cap production deploy:migrations"
alias cptd="cap testing deploy"
alias cptdm="cap testing deploy:migrations"
You need to be covered if something goes wrong. You need to backup static assets and database. I will not go into this here. Ideally, backup to an offsite location. eg. Amazon S3.
Make sure you have the exception notification plugin on the go, so you get emails when things break.
The new relic performance monitoring service is great for keeping an eye on things within your production application. And there is a free version!
Create a production branch in your version control and deploy from that. Then as you work for bugfixes and new features on master you then merge with the production branch for deployment.
To merge master with production.
git checkout production
git merge master
You can then also do critical changes to the production branch. And to get this back into master.
git checkout master
git merge production
Thats all for now. Any comments?