Sha256: b8af413d8f15b28c76f4e7ba5ee2595fff65124b207896c3bf98a26d51226f21

Contents?: true

Size: 1.93 KB

Versions: 1

Compression:

Stored size: 1.93 KB

Contents

namespace :foreman do
  desc <<-DESC
    Export the Procfile to upstart.

    You can override any of these defaults by setting the variables shown below.

    set :foreman_format,      "upstart"
    set :foreman_location,    "/etc/init"
    set :foreman_port,        5000
    set :foreman_root,        -> { release_path }
    set :foreman_procfile,    -> { release_path.join('Procfile') }
    set :foreman_app,         -> { fetch(:application) }
    set :foreman_user,        -> { fetch(:user) }
    set :foreman_log,         -> { shared_path.join('log') }
    set :foreman_concurrency, false
    set :foreman_sudo,        false
  DESC

  task :export do
    on roles(:all) do
      within release_path do
        concurrency = fetch(:foreman_concurrency)
        sudo        = fetch(:foreman_sudo)

        args  = [fetch(:foreman_format), fetch(:foreman_location)]
        args << %Q(-f #{fetch(:foreman_procfile)})
        args << %Q(-p #{fetch(:foreman_port)})
        args << %Q(-d #{fetch(:foreman_root)})
        args << %Q(-a #{fetch(:foreman_app)})
        args << %Q(-u #{fetch(:foreman_user)})
        args << %Q(-l #{fetch(:foreman_log)})
        args << %Q(-c #{concurrency}) if concurrency

        cmd = "foreman export #{args.join(' ')}"

        if sudo
          execute "sudo su - -c '#{cmd}'"
        else
          execute cmd
        end
      end
    end
  end
end

namespace :load do
  task :defaults do
    set :foreman_format,      "upstart"
    set :foreman_location,    "/etc/init"
    set :foreman_port,        5000
    set :foreman_root,        -> { release_path }
    set :foreman_procfile,    -> { release_path.join('Procfile') }
    set :foreman_app,         -> { fetch(:application) }
    set :foreman_user,        -> { fetch(:user) }
    set :foreman_log,         -> { shared_path.join('log') }
    set :foreman_concurrency, false
    set :foreman_sudo,        false
  end
end

namespace :deploy do
  after :updated, 'foreman:export'
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mascherano-1.0.0 lib/mascherano/tasks/foreman.cap