Sha256: 4a5260a06b356c45531a9a9818735f5ddf5e31804db9758fb1e2adf56bfa26b2

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

namespace :foreman do

  desc "Export the Procfile to Ubuntu upstart scripts"
  task :export do
    export_cmd = "sudo bundle exec foreman export upstart /etc/init -a #{foreman_app} -u #{foreman_user} -l #{foreman_log} -d #{deploy_to!}/current"

    queue %{
      echo "-----> Exporting foreman procfile for #{foreman_app}"
      #{echo_cmd %[cd #{deploy_to!}/#{current_path!} ; #{export_cmd}]}
    }
  end

  File.readlines("Procfile").map{ |line| line.split(": ").first }.each do |p|
    set_default "foreman_#{p}_app".to_sym, -> { "#{settings.foreman_app}-#{p}" }

    namespace p.to_sym do
      desc "Start the #{p} services"
      task :start do
        queue %{
          echo "-----> Starting #{p} services"
          #{echo_cmd %[sudo start #{send("foreman_#{p}_app")}]}
        }
      end

      desc "Stop the #{p} services"
      task :stop do
        queue %{
          echo "-----> Stopping #{p} services"
          #{echo_cmd %[sudo stop #{send("foreman_#{p}_app")}]}
        }
      end

      desc "Restart the #{p} services"
      task :restart do
        queue %{
          echo "-----> Restarting #{p} services"
          #{echo_cmd %[sudo start #{send("foreman_#{p}_app")} || sudo restart #{send("foreman_#{p}_app")}]}
        }
      end
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
self_systeem-0.1.0 test/dummy_app/lib/recipes/foreman.rb