Sha256: acb30c8afa6b73fe8d6ae07f09fb6738a6a4da3876b512de36b1e4470d8b8c5a

Contents?: true

Size: 1.91 KB

Versions: 1

Compression:

Stored size: 1.91 KB

Contents

git_plugin = self

namespace :puma do
  namespace :jungle do
    desc 'Install Puma jungle'
    task :install do
      on roles(fetch(:puma_role)) do |role|
        git_plugin.template_puma 'run-puma', "#{fetch(:tmp_dir)}/run-puma", role
        execute "chmod +x #{fetch(:tmp_dir)}/run-puma"
        sudo "mv #{fetch(:tmp_dir)}/run-puma #{fetch(:puma_run_path)}"
        if test '[ -f /etc/redhat-release ]'
          #RHEL flavor OS
          git_plugin.rhel_install(role)
          execute "chmod +x #{fetch(:tmp_dir)}/puma"
          sudo "mv #{fetch(:tmp_dir)}/puma /etc/init.d/puma"
          sudo 'chkconfig --add puma'
        elsif test '[ -f /etc/lsb-release ]'
          #Debian flavor OS
          git_plugin.debian_install(role)
          execute "chmod +x #{fetch(:tmp_dir)}/puma"
          sudo "mv #{fetch(:tmp_dir)}/puma /etc/init.d/puma"
          sudo 'update-rc.d -f puma defaults'
        else
          #Some other OS
          error 'This task is not supported for your OS'
        end
        sudo "touch #{fetch(:puma_jungle_conf)}"
      end
    end

    desc 'Setup Puma config and install jungle script'
    task :setup do
      invoke 'puma:config'
      invoke 'puma:jungle:install'
      invoke 'puma:jungle:add'
    end

    desc 'Add current project to the jungle'
    task :add do
      on roles(fetch(:puma_role)) do|role|
        begin
          sudo "/etc/init.d/puma add '#{current_path}' #{fetch(:puma_user, role.user)}"
        rescue => error
          warn error
        end
      end
    end

    desc 'Remove current project from the jungle'
    task :remove do
      on roles(fetch(:puma_role)) do
        sudo "/etc/init.d/puma remove '#{current_path}'"
      end
    end

    %w[start stop restart status].each do |command|
      desc "#{command} puma"
      task command do
        on roles(fetch(:puma_role)) do
          sudo "service puma #{command} #{current_path}"
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
capistrano3-puma-3.1.1 lib/capistrano/tasks/jungle.rake