Sha256: 164240114bf80a4b468cc362369458ee6b294a1728ff73c308f617be7aae19b1

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

def build_cmd(service_name, action, sudo = false)
  cmd = "service #{service_name} #{action}"
  cmd = "sudo " + cmd if sudo
  cmd
end

namespace :upstart do
  desc "Start the application services"
  task :start do
    on roles(fetch(:upstart_roles)) do
      execute build_cmd(fetch(:upstart_service), 'start', fetch(:upstart_sudo))
    end
  end

  desc "Stop the application services"
  task :stop do
    on roles(fetch(:upstart_roles)) do
      execute build_cmd(fetch(:upstart_service), 'stop', fetch(:upstart_sudo))
    end
  end

  desc "Restart the application services"
  task :restart do
    on roles(fetch(:upstart_roles)) do
      cmd_sq  = build_cmd(fetch(:upstart_service), 'start', fetch(:upstart_sudo))
      cmd_sq += ' || '
      cmd_sq += build_cmd(fetch(:upstart_service), 'restart', fetch(:upstart_sudo))

      execute cmd_sq
    end
  end
end

namespace :load do
  task :defaults do
    set :upstart_service, -> { fetch(:application) }
    set :upstart_sudo, false
    set :upstart_roles, :app
  end
end

namespace :deploy do
  after :publishing, 'upstart:restart'
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mascherano-1.1.0 lib/mascherano/tasks/upstart.cap
mascherano-1.0.4 lib/mascherano/tasks/upstart.cap
mascherano-1.0.3 lib/mascherano/tasks/upstart.cap
mascherano-1.0.2 lib/mascherano/tasks/upstart.cap