Sha256: 91a4d4f106965d8d5dec803abb137051f921f063a972d5e3926967e5ef3454d0

Contents?: true

Size: 1.35 KB

Versions: 3

Compression:

Stored size: 1.35 KB

Contents

namespace :deploy do
  set :bundle_binstubs, -> { shared_path.join('bin') }

  desc 'Export upstart script'
  task :export_upstart do
    on roles(:app) do
      within current_path do
        sudo fetch(:chruby_exec), "#{fetch(:chruby_ruby)} -- #{fetch(:bundle_binstubs)}/foreman export upstart /etc/init -a #{fetch(:application)} -u \`whoami\` -l #{shared_path}/log"
      end
    end
  end

  task :disable_autostart do
    on roles(:app) do
      execute "/bin/echo manual | sudo /usr/bin/tee /etc/init/#{fetch(:application)}.override"
    end
  end

  task :enable_autostart do
    on roles(:app) do
      execute "/bin/echo | sudo /usr/bin/tee /etc/init/#{fetch(:application)}.override"
    end
  end

  namespace :foreman do
    desc 'Upload Procfile to server'
    task :upload_procfile do
      on roles(:app) do
        upload! 'tmp/Procfile', "#{fetch(:deploy_to)}/current/Procfile"
      end
    end

    desc 'Generate Procfile'
    task  :generate_procfile do
      Dir.mkdir('tmp') unless Dir.exist?('tmp')

      File.open('tmp/Procfile', 'w') do |conf|
        fetch(:procfile_contents).each_line do |line|
          conf.puts "#{line.chomp} 2>&1 | logger -t #{fetch(:app_name)}"
        end
      end
    end
  end

  before 'deploy:export_upstart', 'deploy:foreman:upload_procfile'
  before 'deploy:foreman:upload_procfile', 'deploy:foreman:generate_procfile'
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
capistrano-twingly-2.3.0 lib/capistrano/twingly/tasks/upstart.rake
capistrano-twingly-2.2.0 lib/capistrano/twingly/tasks/upstart.rake
capistrano-twingly-2.1.0 lib/capistrano/twingly/tasks/upstart.rake