Developer’s checklist: Production deployment

One has to be very careful for shipping new changes/features to the production server.

When feature is said to be done

Assumption: Proper development processes have been followed

  1. Smoke Test in local machine
  2. Production Database backups
    • Generate snapshots or database-dumps
    • Store the backups in safe places
    • In case of Heroku, you will be provided with backup-tools
  3. Codebase versioning in Github / Diffusion
    • Create tags with proper naming conventions followed
    • eg V 0.1.1 or V 1.0.0 pre
  4. Deployment to production
    • Deploy the changes to the server
    • Make sure you run rake db:migrate is any migration pending
  5. Do data migrations if required
    • Already existing Production data might not co-op with your new code changes
      • reasons: there might be some data-fields manipulations or
        • new cols might have been added and data need to be filled in; data to be gathered from existing fields
    • Document the migration code you wrote for data-migrations [remember I am not taking about schema migrations]
    • eg
TransactionHistory.recurring_rewards.each do |tx|
   charge = Stripe::Charge.retrieve(tx.charge_id)
   invoice = Stripe::Invoice.retrieve(charge.invoice)
   subscription_id = invoice.subscription
   metadata = tx.transaction_additional_detail.metadata
   tx.transaction_additional_detail.update metadata: metadata.deep_merge(
                                               subscription_id: subscription_id,
  1. Smoke test in production

Capistrano 3.0 : Task Flow : Rails deployment

Deploy flow

When you run cap production deploy, it invokes the following tasks in sequence:

deploy:starting    - start a deployment, make sure everything is ready
deploy:started     - started hook (for custom tasks)
deploy:updating    - update server(s) with a new release
deploy:updated     - updated hook
deploy:publishing  - publish the new release
deploy:published   - published hook
deploy:finishing   - finish the deployment, clean up everything
deploy:finished    - finished hook

Notice there are several hook tasks e.g. :started, :updated for you to hook up custom tasks into the flow using after() and before().

Flow examples

Continue reading

Capistrano 3.0 for Rails app deployment

Capistrano is designed to run commands remotely. To do this we’ll need to specify a server, which we do by calling server. We need to pass this the address of a server and a role. We’ll explain roles later; for now we’ll just set this to web.

First you need to set the configurations. Common settings go to the `deploy.rb` and environment specific settings goes to either 'config/deploy/production.rb' or 'staging.rb'

Continue reading

Capistrano 3 : Invoke one custom made task from another task

In previous versions, it was like normal ruby of JavaScript function call

You can do it by using namespace:

namespace :test do
  task :one do
  task :two do
    # or just directly call it:

Just be careful with the name you use to not overwrite some important function.
Continue reading

Ruby On Rails: Deploy on Engineyard server

Platform as a service (PaaS) is a category of cloud computing services that provides a platform allowing customers to develop, run and manage Web applications without the complexity of building and maintaining the infrastructure typically associated with developing and launching an app.[1]

Features of Engineyard PaaS[2]

Managed Application Runtime

Continue reading