Sha256: 49f15e6fa9753c079118263a8bb6984859cccecc1bb5dceaeb00ebbe3f3f5eb3

Contents?: true

Size: 1.89 KB

Versions: 2

Compression:

Stored size: 1.89 KB

Contents

namespace :puma do

  desc "Setup puma configuration for this application"
  task :config do
    on roles(:web) do
      template "puma.rb.erb", "/tmp/puma_conf"
      sudo "mv /tmp/puma_conf #{shared_path}/config/puma.rb"
    end
  end
  namespace :sysvinit do
    task :setup do
      on roles(:web) do
        template "puma_init.erb", "/tmp/puma"
        sudo "mv /tmp/puma /etc/init.d/#{fetch(:application)}"
        sudo "chmod +x /etc/init.d/#{fetch(:application)}"
        sudo "update-rc.d #{fetch(:application)} defaults"
        template "nginx_puma_config.erb", "/tmp/nginx_puma_config"
        sudo "mv /tmp/nginx_puma_config /etc/nginx/sites-enabled/#{fetch(:application)}"
      end
    end

    %w[start stop restart reload].each do |command|
      desc "#{command} puma"
      task command do
        on roles(:web) do
          execute "/etc/init.d/#{fetch(:application)} #{command}"
        end
      end
    end
  end
  namespace :supervisor do
    task :setup do
      on roles(:web) do
        template "puma_supervisor.erb", "/tmp/puma"
        sudo "mv /tmp/puma /etc/supervisor/conf.d/#{fetch(:application)}.conf"
        sudo "supervisorctl reread"
        sudo "supervisorctl update" # it will auto start the application
        template "nginx_puma_config.erb", "/tmp/nginx_puma_config"
        sudo "mv /tmp/nginx_puma_config /etc/nginx/sites-enabled/#{fetch(:application)}"
      end
    end

    task :start do
      on roles(:web) do
        execute "supervisorctl start #{fetch(:application)}"
      end
    end
    task :stop do
      on roles(:web) do
        execute "supervisorctl signal INT #{fetch(:application)}"
      end
    end
    task :restart do
      on roles(:web) do
        execute "supervisorctl signal USR1 #{fetch(:application)}"
      end
    end
    task :reload do
      on roles(:web) do
        execute "supervisorctl signal USR2 #{fetch(:application)}"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pixelforce_recipes-2.1 lib/pixelforce_recipes/capistrano_3_recipes/puma.rb
pixelforce_recipes-2.0 lib/pixelforce_recipes/capistrano_3_recipes/puma.rb