deployment snippets

Vlad deployment recipe for Phusion Passenger

Tagged vlad, phusion, passenger, apache, deployment  Languages ruby
# General configuration
#set :ssh_flags,             '-p 110000'
set :application,           ''
set :domain,                'x.x.x.x'
set :deploy_to,             '/var/www/'
set :revision,              'master'
set :repository,            '/var/lib/git/repositories/'

namespace :vlad do
  set :app_command, "/etc/init.d/apache2"
  desc 'Restart Passenger'
  remote_task :start_app, :roles => :app do
    run "touch #{current_release}/tmp/restart.txt"
  desc 'Restarts the apache servers'
  remote_task :start_web, :roles => :app do
    run "sudo #{app_command} restart"

Elixir Deployment

Tagged deployment, elixir, exrm, deploy, rollback, upgrade, distillery  Languages bash, elixir


Development environment:

  1. Sign up for a Gitlab account, or use your favorite git server
  2. Create a (private) repository
  3. Create a deploy key that allows read-only access to your private repository (optional, if public)
  4. Commit code to the repository


You will need Elixir:

$ sudo apt-get install elixir


Add distillery to the list of dependencies:

def deps do
   {:distillery, "~> 0.9.9"},

Run mix release.init and follow the instructions:

$ mix release.init

An example config file has been placed in rel/config.exs, review it,
make edits as needed/desired, and then run `mix release` to build the release

Next, run mix release:

You can run it in one of the following ways:
  Interactive: rel/xxx/bin/xxx console
  Foreground: rel/xxx/bin/xxx foreground
  Daemon: rel/xxx/bin/xxx start


Production environment:

  1. Clone project
$ cd /var/www
$ git clone
  1. Create a release
$ MIX_ENV=prod mix do deps.get, clean, compile
$ MIX_ENV=prod mix release --verbosity=verbose
  1. Create a monit start script
# Run "ps -ef | grep beam, if you get status "Does not exist" from "monit status"
check process snippets MATCHING "rel/snippets"
    start program = "/bin/su - deploy -c '/var/www/aktagon-snippets/rel/snippets/bin/snippets start'"
    stop program = "/bin/su - deploy -c '/var/www/aktagon-snippets/rel/snippets/bin/snippets stop'"
  1. Start server
$ sudo monit start snippets

Deploying a new version

First increment the version number. Then perform the hot upgrade:

$ git pull
$ export MIX_ENV=prod
$ mix do compile
$ mix release --upgrade 

$ rel/snippets/bin/snippets upgrade "0.0.2"

Rolling back to a previous version

How to perform hot downgrades:

$ rel/snippets/bin/snippets downgrade "0.0.1"



See Using Distillery With Phoenix.