Sha256: 8da9bbd6dc535341d452935086a968b35aa3a51f3f5bd8acd697e6c214582913

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

namespace :load do
  task :defaults do
    set :phoenix_role, -> { :app }
    set :phoenix_mix_env, -> { fetch(:mix_env) }
  end
end

namespace :phoenix do
  def is_application_running?()
    pid = capture(%Q{ps ax -o pid= -o command=|grep "rel/#{fetch(:application)}/.*/[b]eam"|awk '{print $1}'})
    return pid != ""
  end

  desc 'ping'
  task :ping do
    on roles(fetch(:phoenix_role)), in: :sequence do
      within current_path  do
        execute "rel/#{fetch(:application)}/bin/#{fetch(:application)}", "ping"
      end
    end
  end

  desc 'build'
  task :build do
    on roles(fetch(:phoenix_role)), in: :sequence do
      within release_path  do
        execute :mix, "do deps.get, compile && MIX_ENV=#{fetch(:phoenix_mix_env)} mix phoenix.digest && MIX_ENV=#{fetch(:phoenix_mix_env)} mix release"
      end
    end
  end

  desc 'restart phoenix app'
  task :restart do
    on roles(fetch(:phoenix_role)), in: :sequence do
      within current_path  do

        if is_application_running?
          execute "rel/#{fetch(:application)}/bin/#{fetch(:application)}", "stop"
        end
        execute "rel/#{fetch(:application)}/bin/#{fetch(:application)}", "start -detached"
      end
    end
  end
end

namespace :deploy do
  after :publishing, "phoenix:build"
  after :published, "phoenix:restart"
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
capistrano-phoenix-0.1.0 lib/capistrano/tasks/capistrano.cap