capistrano-pumaio 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +9 -0
- data/Gemfile.lock +69 -0
- data/LICENSE +20 -0
- data/README.md +62 -0
- data/Rakefile +37 -0
- data/VERSION +1 -0
- data/capistrano-puma/config.rb +47 -0
- data/capistrano-puma/monit.rb +70 -0
- data/capistrano-puma/runit.rb +89 -0
- data/capistrano-pumaio.rb +11 -0
- data/templates/monit/puma.conf.erb +16 -0
- data/templates/runit/config.rb.erb +14 -0
- data/templates/runit/control-q.erb +5 -0
- data/templates/runit/log-run.erb +10 -0
- data/templates/runit/run.erb +9 -0
- metadata +129 -0
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
addressable (2.3.5)
|
5
|
+
builder (3.2.2)
|
6
|
+
capistrano (2.15.5)
|
7
|
+
highline
|
8
|
+
net-scp (>= 1.0.0)
|
9
|
+
net-sftp (>= 2.0.0)
|
10
|
+
net-ssh (>= 2.0.14)
|
11
|
+
net-ssh-gateway (>= 1.1.0)
|
12
|
+
capistrano-base_helper (0.0.3)
|
13
|
+
capistrano (>= 2.15.5)
|
14
|
+
faraday (0.8.7)
|
15
|
+
multipart-post (~> 1.1)
|
16
|
+
git (1.2.5)
|
17
|
+
github_api (0.10.1)
|
18
|
+
addressable
|
19
|
+
faraday (~> 0.8.1)
|
20
|
+
hashie (>= 1.2)
|
21
|
+
multi_json (~> 1.4)
|
22
|
+
nokogiri (~> 1.5.2)
|
23
|
+
oauth2
|
24
|
+
hashie (2.0.5)
|
25
|
+
highline (1.6.19)
|
26
|
+
httpauth (0.2.0)
|
27
|
+
jeweler (1.8.6)
|
28
|
+
builder
|
29
|
+
bundler (~> 1.0)
|
30
|
+
git (>= 1.2.5)
|
31
|
+
github_api (= 0.10.1)
|
32
|
+
highline (>= 1.6.15)
|
33
|
+
nokogiri (= 1.5.10)
|
34
|
+
rake
|
35
|
+
rdoc
|
36
|
+
json (1.8.0)
|
37
|
+
jwt (0.1.8)
|
38
|
+
multi_json (>= 1.5)
|
39
|
+
multi_json (1.7.7)
|
40
|
+
multi_xml (0.5.4)
|
41
|
+
multipart-post (1.2.0)
|
42
|
+
net-scp (1.1.1)
|
43
|
+
net-ssh (>= 2.6.5)
|
44
|
+
net-sftp (2.1.2)
|
45
|
+
net-ssh (>= 2.6.5)
|
46
|
+
net-ssh (2.6.7)
|
47
|
+
net-ssh-gateway (1.2.0)
|
48
|
+
net-ssh (>= 2.6.5)
|
49
|
+
nokogiri (1.5.10)
|
50
|
+
oauth2 (0.9.2)
|
51
|
+
faraday (~> 0.8)
|
52
|
+
httpauth (~> 0.2)
|
53
|
+
jwt (~> 0.1.4)
|
54
|
+
multi_json (~> 1.0)
|
55
|
+
multi_xml (~> 0.5)
|
56
|
+
rack (~> 1.2)
|
57
|
+
rack (1.5.2)
|
58
|
+
rake (10.1.0)
|
59
|
+
rdoc (4.0.1)
|
60
|
+
json (~> 1.4)
|
61
|
+
|
62
|
+
PLATFORMS
|
63
|
+
ruby
|
64
|
+
|
65
|
+
DEPENDENCIES
|
66
|
+
bundler (>= 1.3.0)
|
67
|
+
capistrano (>= 2.15.5)
|
68
|
+
capistrano-base_helper (>= 0.0.3)
|
69
|
+
jeweler (~> 1.8.6)
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 Leif Ringstad
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# Capistrano Recipes for Puma
|
2
|
+
|
3
|
+
This gem provides recipes for [Puma](http://puma.io) to setup runit and monit
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
|
8
|
+
Add it to your Gemfile without requiring it
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'capistrano-pumaio', require: false
|
12
|
+
```
|
13
|
+
|
14
|
+
In your deploy.rb:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
require 'capistrano-pumaio'
|
18
|
+
```
|
19
|
+
|
20
|
+
|
21
|
+
### Monit
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
cap puma:monit:disable # Disable and stop monit services for puma
|
25
|
+
cap puma:monit:enable # Enable monit services for puma
|
26
|
+
cap puma:monit:monitor # Monitor puma
|
27
|
+
cap puma:monit:restart # Restart monit services for puma
|
28
|
+
cap puma:monit:setup # Setup Puma monit-service
|
29
|
+
cap puma:monit:start # Start monit services for puma (will also tr...
|
30
|
+
cap puma:monit:stop # Stop monit services for puma (will also sto...
|
31
|
+
cap puma:monit:unmonitor # Purge puma monit configuration
|
32
|
+
```
|
33
|
+
|
34
|
+
### Runit
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
cap puma:runit:disable # Disable Puma runit-service
|
38
|
+
cap puma:runit:enable # Enable Puma runit-service
|
39
|
+
cap puma:runit:flush_sockets # Flush puma sockets, as they can end up 'han...
|
40
|
+
cap puma:runit:once # Start Puma runit-service only ONCE (no supe...
|
41
|
+
cap puma:runit:purge # Purge puma runit configuration
|
42
|
+
cap puma:runit:quit # Quit the puma runit-service
|
43
|
+
cap puma:runit:restart # Restart Puma runit-service
|
44
|
+
cap puma:runit:setup # Setup Puma runit-service
|
45
|
+
cap puma:runit:start # Start Puma runit-service
|
46
|
+
cap puma:runit:stop # Stop Puma runit-service
|
47
|
+
```
|
48
|
+
|
49
|
+
## Configuration
|
50
|
+
|
51
|
+
See puma/config.rb for default options, and ovveride any in your deploy.rb file.
|
52
|
+
|
53
|
+
## Contributing
|
54
|
+
|
55
|
+
* Fork the project
|
56
|
+
* Make a feature addition or bug fix
|
57
|
+
* Please test the feature or bug fix
|
58
|
+
* Make a pull request
|
59
|
+
|
60
|
+
## Copyright
|
61
|
+
|
62
|
+
(c) 2013 Leif Ringstad. See LICENSE for details
|
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "capistrano-pumaio"
|
18
|
+
gem.homepage = "https://github.com/leifcr/capistrano-puma"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Capistrano recipes for puma using runit and monit}
|
21
|
+
gem.description = %Q{Capistrano recipes for puma using runit and monit.}
|
22
|
+
gem.email = "leifcr@gmail.com"
|
23
|
+
gem.authors = ["Leif Ringstad"]
|
24
|
+
gem.files.exclude ".ruby-*"
|
25
|
+
# dependencies defined in Gemfile
|
26
|
+
end
|
27
|
+
Jeweler::RubygemsDotOrgTasks.new
|
28
|
+
|
29
|
+
# require 'rdoc/task'
|
30
|
+
# Rake::RDocTask.new do |rdoc|
|
31
|
+
# version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
32
|
+
|
33
|
+
# rdoc.rdoc_dir = 'rdoc'
|
34
|
+
# rdoc.title = "capistrano-empty #{version}"
|
35
|
+
# rdoc.rdoc_files.include('README*')
|
36
|
+
# rdoc.rdoc_files.include('lib/**/*.rb')
|
37
|
+
# end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.2
|
@@ -0,0 +1,47 @@
|
|
1
|
+
Capistrano::Configuration.instance(true).load do
|
2
|
+
_cset :puma_runit_service_name, "puma"
|
3
|
+
_cset :puma_workers, 2 # Must use a minimum of 1 worker (cluster mode, else restart/stop fails in the state file?)
|
4
|
+
_cset :puma_min_threads, 2
|
5
|
+
_cset :puma_max_threads, 8
|
6
|
+
|
7
|
+
_cset :puma_bin, 'bundle exec puma'
|
8
|
+
_cset :puma_control, 'bundle exec pumactl'
|
9
|
+
|
10
|
+
# Control files
|
11
|
+
_cset :puma_socket_file, "#{File.join(fetch(:sockets_path), "puma.sock")}"
|
12
|
+
_cset :puma_socket_url, "unix://#{fetch(:puma_socket_file)}"
|
13
|
+
_cset :puma_pid_file, File.join(fetch(:pids_path), "puma.pid")
|
14
|
+
_cset :puma_state_file, File.join(fetch(:sockets_path), "puma.state")
|
15
|
+
_cset :puma_control_file, "#{File.join(fetch(:sockets_path), "pumactl.sock")}"
|
16
|
+
_cset :puma_control_url, "unix://#{fetch(:puma_control_file)}"
|
17
|
+
|
18
|
+
_cset :puma_activate_control_app, true
|
19
|
+
|
20
|
+
_cset :puma_on_restart_active, true
|
21
|
+
|
22
|
+
# Logging to path
|
23
|
+
_cset :puma_log_path, defer {"/var/log/service/#{fetch(:user)}/#{fetch(:application)}_#{Capistrano::BaseHelper.environment}/puma"}
|
24
|
+
|
25
|
+
# Configuration files
|
26
|
+
_cset :puma_local_config, File.join(File.expand_path(File.join(File.dirname(__FILE__),"../templates", "runit")), "config.rb.erb")
|
27
|
+
|
28
|
+
# The remote location of puma's config file. Used by runit when starting puma
|
29
|
+
_cset :puma_remote_config, File.join(shared_path, "config", "puma.rb")
|
30
|
+
|
31
|
+
# runit paths
|
32
|
+
_cset :puma_runit_local_config, File.join(File.expand_path(File.join(File.dirname(__FILE__),"../templates", "runit", )), "run.erb")
|
33
|
+
_cset :puma_runit_control_q, File.join(File.expand_path(File.join(File.dirname(__FILE__),"../templates", "runit")), "control-q.erb")
|
34
|
+
_cset :puma_runit_local_log_run, File.join(File.expand_path(File.join(File.dirname(__FILE__),"../templates", "runit")), "log-run.erb")
|
35
|
+
|
36
|
+
# monit configuration
|
37
|
+
_cset :puma_monit_service_name, defer { "#{fetch(:user)}_#{fetch(:application)}_#{Capistrano::BaseHelper.environment}_puma" }
|
38
|
+
_cset :puma_monit_start_command, defer {"/bin/bash -c '[ ! -h #{Capistrano::RunitBase.service_path(fetch(:puma_runit_service_name))}/run ] || /usr/bin/sv start #{Capistrano::RunitBase.service_path(fetch(:puma_runit_service_name))}'"}
|
39
|
+
_cset :puma_monit_stop_command, defer {"/usr/bin/sv -w 12 force-stop #{Capistrano::RunitBase.service_path(fetch(:puma_runit_service_name))}"}
|
40
|
+
_cset :puma_monit_memory_alert_threshold, "150.0 MB for 2 cycles"
|
41
|
+
_cset :puma_monit_memory_restart_threshold, "175.0 MB for 3 cycles"
|
42
|
+
_cset :puma_monit_cpu_alert_threshold, "90% for 2 cycles"
|
43
|
+
_cset :puma_monit_cpu_restart_threshold, "95% for 5 cycles"
|
44
|
+
|
45
|
+
_cset :puma_local_monit_config, File.join(File.expand_path(File.join(File.dirname(__FILE__),"../templates", "monit")), "puma.conf.erb")
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# Puma - Monit
|
2
|
+
# Setup and management of Monit for Puma
|
3
|
+
#
|
4
|
+
require 'capistrano-base_helper/base_helper'
|
5
|
+
require 'capistrano-base_helper/monit_base'
|
6
|
+
|
7
|
+
Capistrano::Configuration.instance(true).load do
|
8
|
+
after "monit:setup", "puma:monit:setup"
|
9
|
+
after "puma:monit:setup", "puma:monit:enable"
|
10
|
+
after "puma:monit:enable", "monit:reload"
|
11
|
+
|
12
|
+
before "puma:monit.disable", "puma:monit:unmonitor"
|
13
|
+
after "puma:monit:disable", "monit:reload"
|
14
|
+
|
15
|
+
# start service after update in case it has not been stopped
|
16
|
+
# after "deploy:update", "puma:monit:start"
|
17
|
+
# Not needed?
|
18
|
+
|
19
|
+
namespace :puma do
|
20
|
+
namespace :monit do
|
21
|
+
desc "Setup Puma monit-service"
|
22
|
+
task :setup, :roles => [:app, :web, :db] do
|
23
|
+
# Upload configuration
|
24
|
+
Capistrano::BaseHelper::generate_and_upload_config(puma_local_monit_config, File.join(fetch(:monit_available_path), "#{fetch(:puma_runit_service_name)}.conf"))
|
25
|
+
# Enable monitor
|
26
|
+
end
|
27
|
+
|
28
|
+
desc "Enable monit services for Puma"
|
29
|
+
task :enable, :roles => [:app, :web, :db] do
|
30
|
+
Capistrano::MonitBase::Service.enable("#{fetch(:puma_runit_service_name)}.conf")
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "Disable and stop monit services for Puma"
|
34
|
+
task :disable, :roles => [:app, :web, :db] do
|
35
|
+
Capistrano::MonitBase::Service.disable("#{fetch(:puma_runit_service_name)}.conf")
|
36
|
+
end
|
37
|
+
|
38
|
+
desc "Start monit services for Puma (will also try to start the service)"
|
39
|
+
task :start, :roles => [:app, :web, :db] do
|
40
|
+
Capistrano::MonitBase::Service.command_monit("start", fetch(:puma_monit_service_name))
|
41
|
+
end
|
42
|
+
|
43
|
+
desc "Stop monit services for Puma (will also stop the service)"
|
44
|
+
task :stop, :roles => [:app, :web, :db] do
|
45
|
+
Capistrano::MonitBase::Service.command_monit("stop", fetch(:puma_monit_service_name))
|
46
|
+
end
|
47
|
+
|
48
|
+
desc "Restart monit services for Puma"
|
49
|
+
task :restart, :roles => [:app, :web, :db] do
|
50
|
+
Capistrano::MonitBase::Service.command_monit("restart", fetch(:puma_monit_service_name))
|
51
|
+
end
|
52
|
+
|
53
|
+
desc "Monitor Puma"
|
54
|
+
task :monitor, :roles => [:app, :web, :db] do
|
55
|
+
Capistrano::MonitBase::Service.command_monit("monitor", fetch(:puma_monit_service_name))
|
56
|
+
end
|
57
|
+
|
58
|
+
desc "Unmonitor Puma"
|
59
|
+
task :unmonitor, :roles => [:app, :web, :db] do
|
60
|
+
Capistrano::MonitBase::Service.command_monit("unmonitor", fetch(:puma_monit_service_name))
|
61
|
+
end
|
62
|
+
|
63
|
+
desc "Purge Puma monit configuration"
|
64
|
+
task :unmonitor, :roles => [:app, :web, :db], :on_error => :continue do
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# Puma - Runit
|
2
|
+
|
3
|
+
require 'capistrano-base_helper/base_helper'
|
4
|
+
require 'capistrano-base_helper/runit_base'
|
5
|
+
|
6
|
+
Capistrano::Configuration.instance(true).load do
|
7
|
+
after "deploy:setup", "puma:runit:setup"
|
8
|
+
|
9
|
+
# enable service after update in case it has not been setup or is disabled
|
10
|
+
# Service should probably be started as well?
|
11
|
+
after "deploy:update", "puma:runit:enable"
|
12
|
+
before "puma:runit:setup", "puma:runit:flush_sockets"
|
13
|
+
after "puma:runit:quit", "puma:runit:stop"
|
14
|
+
|
15
|
+
namespace :puma do
|
16
|
+
namespace :runit do
|
17
|
+
desc "Setup Puma runit-service"
|
18
|
+
task :setup, :roles => :app do
|
19
|
+
Capistrano::BaseHelper.prepare_path(File.join(fetch(:shared_path), "sockets"), fetch(:user), fetch(:group))
|
20
|
+
|
21
|
+
# Create puma configuration file
|
22
|
+
Capistrano::BaseHelper::generate_and_upload_config(fetch(:puma_local_config), fetch(:puma_remote_config))
|
23
|
+
|
24
|
+
# Create runit config
|
25
|
+
Capistrano::RunitBase.create_service_dir(puma_runit_service_name)
|
26
|
+
Capistrano::BaseHelper::generate_and_upload_config(puma_runit_local_config, Capistrano::RunitBase.remote_run_config_path(puma_runit_service_name))
|
27
|
+
#must use quit script for stop as well
|
28
|
+
Capistrano::BaseHelper::generate_and_upload_config(puma_runit_control_q, Capistrano::RunitBase.remote_control_path(puma_runit_service_name, "q"))
|
29
|
+
Capistrano::BaseHelper::generate_and_upload_config(puma_runit_control_q, Capistrano::RunitBase.remote_control_path(puma_runit_service_name, "s"))
|
30
|
+
Capistrano::BaseHelper::generate_and_upload_config(puma_runit_local_log_run, Capistrano::RunitBase.remote_service_log_run_path(puma_runit_service_name))
|
31
|
+
|
32
|
+
# Make scripts executable
|
33
|
+
Capistrano::RunitBase.make_service_scripts_executeable(puma_runit_service_name)
|
34
|
+
# Set correct permissions/owner on log path
|
35
|
+
Capistrano::RunitBase.create_and_permissions_on_path(fetch(:puma_log_path))
|
36
|
+
end
|
37
|
+
|
38
|
+
desc "Enable Puma runit-service"
|
39
|
+
task :enable, :roles => :app do
|
40
|
+
Capistrano::RunitBase.enable_service(puma_runit_service_name)
|
41
|
+
end
|
42
|
+
|
43
|
+
desc "Disable Puma runit-service"
|
44
|
+
task :disable, :roles => :app do
|
45
|
+
Capistrano::RunitBase.disable_service(puma_runit_service_name)
|
46
|
+
end
|
47
|
+
|
48
|
+
desc "Start Puma runit-service"
|
49
|
+
task :start, :roles => :app do
|
50
|
+
Capistrano::RunitBase.start_service(puma_runit_service_name)
|
51
|
+
end
|
52
|
+
|
53
|
+
desc "Start Puma runit-service only ONCE (no supervision...)"
|
54
|
+
task :once, :roles => :app do
|
55
|
+
Capistrano::RunitBase.start_service_once(puma_runit_service_name)
|
56
|
+
end
|
57
|
+
|
58
|
+
desc "Stop Puma runit-service"
|
59
|
+
task :stop, :roles => :app, :on_error => :continue do
|
60
|
+
# have to use force-stop on failed stop, since puma might not terminate properly
|
61
|
+
# will wait 25 seconds for puma to shut down, to allow it to serve any on-going requests
|
62
|
+
Capistrano::RunitBase.control_service(puma_runit_service_name, "force-stop", false, "-w 25")
|
63
|
+
end
|
64
|
+
|
65
|
+
desc "Quit the puma runit-service"
|
66
|
+
task :quit, :roles => :app, :on_error => :continue do
|
67
|
+
Capistrano::RunitBase.control_service(puma_runit_service_name, "quit")
|
68
|
+
end
|
69
|
+
|
70
|
+
desc "Restart Puma runit-service"
|
71
|
+
task :restart, :roles => :app do
|
72
|
+
# Send USR2 to puma in order to restart it....
|
73
|
+
Capistrano::RunitBase.control_service(puma_runit_service_name, "2")
|
74
|
+
end
|
75
|
+
|
76
|
+
desc "Flush Puma sockets, as they can end up 'hanging around'"
|
77
|
+
task :flush_sockets, :roles => :app do
|
78
|
+
run "rm -f #{fetch(:puma_socket_file)}; rm -f #{fetch(:puma_control_file)}"
|
79
|
+
end
|
80
|
+
|
81
|
+
desc "Purge Puma runit configuration"
|
82
|
+
task :purge, :roles => :app, :on_error => :continue do
|
83
|
+
Capistrano::RunitBase.force_control_service(puma_runit_service_name, "force-stop", true)
|
84
|
+
Capistrano::RunitBase.purge_service(puma_runit_service_name)
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
def try_require(library)
|
2
|
+
begin
|
3
|
+
require "#{library}"
|
4
|
+
rescue LoadError => e
|
5
|
+
puts "Capistrano-Puma: Cannot load library: #{library} Error: #{e}"
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
try_require 'capistrano-puma/config'
|
10
|
+
try_require 'capistrano-puma/runit'
|
11
|
+
try_require 'capistrano-puma/monit'
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# Monit configuration for Puma
|
2
|
+
# <% c = Capistrano::BaseHelper::get_capistrano_instance %>
|
3
|
+
# <%= "#{c.fetch(:application)} running as #{c.fetch(:user)} in environment #{Capistrano::BaseHelper.environment}" %>
|
4
|
+
#
|
5
|
+
# Service name: <%= c.fetch(:puma_monit_service_name) %>
|
6
|
+
#
|
7
|
+
check process <%= c.fetch(:puma_monit_service_name) %>
|
8
|
+
with pidfile <%= c.fetch(:puma_pid_file) %>
|
9
|
+
start program = "<%= c.fetch(:puma_monit_start_command) %>"
|
10
|
+
stop program = "<%= c.fetch(:puma_monit_stop_command) %>"
|
11
|
+
if mem is greater than <%= c.fetch(:puma_monit_memory_alert_threshold) %> then alert
|
12
|
+
if mem is greater than <%= c.fetch(:puma_monit_memory_restart_threshold) %> then restart
|
13
|
+
if cpu is greater than <%= c.fetch(:puma_monit_cpu_alert_threshold) %> then alert
|
14
|
+
if cpu is greater than <%= c.fetch(:puma_monit_cpu_restart_threshold) %> then restart
|
15
|
+
|
16
|
+
group <%= c.fetch(:monit_application_group_name) %>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Puma configuration for: <% c = Capistrano::BaseHelper::get_capistrano_instance %>
|
2
|
+
# <%= "#{c.fetch(:application)} running as #{c.fetch(:user)} in environment #{Capistrano::BaseHelper.environment}" %>
|
3
|
+
workers <%= c.fetch(:puma_workers) %>
|
4
|
+
threads <%= c.fetch(:puma_min_threads) %>, <%= c.fetch(:puma_max_threads) %>
|
5
|
+
bind '<%= c.fetch(:puma_socket_url) %>'
|
6
|
+
pidfile '<%= c.fetch(:puma_pid_file) %>'
|
7
|
+
state_path '<%= c.fetch(:puma_state_file) %>'
|
8
|
+
environment '<%= "#{Capistrano::BaseHelper.environment}" %>'
|
9
|
+
<%= "activate_control_app '#{c.fetch(:puma_control_url)}'" if c.fetch(:puma_activate_control_app) %>
|
10
|
+
|
11
|
+
# TODO - fix restart block!
|
12
|
+
# <%= "on_restart do" if c.fetch(:puma_on_restart_active) %>
|
13
|
+
# <%= " puts \"Restarting puma\"" if c.fetch(:puma_on_restart_active) %>
|
14
|
+
# <%= "end" if c.fetch(:puma_on_restart_active) %>
|
@@ -0,0 +1,5 @@
|
|
1
|
+
#!/bin/bash --login
|
2
|
+
# The command used when puma is asked to quit/stop/exit, overridden here, as runit normal signal will not work with puma
|
3
|
+
<% c = Capistrano::BaseHelper::get_capistrano_instance %>
|
4
|
+
cd '<%= c.current_path %>'
|
5
|
+
RAILS_ENV=<%= Capistrano::BaseHelper.environment %> exec <%= c.fetch(:puma_control) %> -S <%= c.fetch(:puma_state_file) %> stop
|
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/bin/sh -e
|
2
|
+
<% c = Capistrano::BaseHelper::get_capistrano_instance %>
|
3
|
+
# Log output for puma running on <%= c.fetch(:application) %> running as <%= c.fetch(:user) %>
|
4
|
+
# make sure the log directory exists
|
5
|
+
mkdir -p "<%= c.fetch(:puma_log_path) %>"
|
6
|
+
# change path to the log directory
|
7
|
+
cd "<%= c.fetch(:puma_log_path) %>"
|
8
|
+
# start logging
|
9
|
+
# exec chpst -u syslog svlogd -tt "<%= c.fetch(:puma_log_path) %>"
|
10
|
+
exec svlogd -tt "<%= c.fetch(:puma_log_path) %>"
|
@@ -0,0 +1,9 @@
|
|
1
|
+
#!/bin/bash --login
|
2
|
+
# Start puma service
|
3
|
+
<% c = Capistrano::BaseHelper::get_capistrano_instance %>
|
4
|
+
# remove pumactl.sock and puma.sock if existing, as puma doesn't overwrite and files may be
|
5
|
+
# existing after server crash or if puma wasnt shutdown properly.
|
6
|
+
rm -f "<%= c.fetch(:puma_socket_file) %>"
|
7
|
+
rm -f "<%= c.fetch(:puma_control_file) %>"
|
8
|
+
cd '<%= c.current_path %>'
|
9
|
+
RAILS_ENV=<%= Capistrano::BaseHelper.environment %> exec <%= c.fetch(:puma_bin) %> -C <%= c.fetch(:puma_remote_config) %>
|
metadata
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-pumaio
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Leif Ringstad
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-07-05 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: capistrano
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.15.5
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 2.15.5
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: capistrano-base_helper
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 0.0.3
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.0.3
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: bundler
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 1.3.0
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.3.0
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: jeweler
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.8.6
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 1.8.6
|
78
|
+
description: Capistrano recipes for puma using runit and monit.
|
79
|
+
email: leifcr@gmail.com
|
80
|
+
executables: []
|
81
|
+
extensions: []
|
82
|
+
extra_rdoc_files:
|
83
|
+
- LICENSE
|
84
|
+
- README.md
|
85
|
+
files:
|
86
|
+
- Gemfile
|
87
|
+
- Gemfile.lock
|
88
|
+
- LICENSE
|
89
|
+
- README.md
|
90
|
+
- Rakefile
|
91
|
+
- VERSION
|
92
|
+
- capistrano-puma/config.rb
|
93
|
+
- capistrano-puma/monit.rb
|
94
|
+
- capistrano-puma/runit.rb
|
95
|
+
- capistrano-pumaio.rb
|
96
|
+
- templates/monit/puma.conf.erb
|
97
|
+
- templates/runit/config.rb.erb
|
98
|
+
- templates/runit/control-q.erb
|
99
|
+
- templates/runit/log-run.erb
|
100
|
+
- templates/runit/run.erb
|
101
|
+
homepage: https://github.com/leifcr/capistrano-puma
|
102
|
+
licenses:
|
103
|
+
- MIT
|
104
|
+
post_install_message:
|
105
|
+
rdoc_options: []
|
106
|
+
require_paths:
|
107
|
+
- lib
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
none: false
|
110
|
+
requirements:
|
111
|
+
- - ! '>='
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
segments:
|
115
|
+
- 0
|
116
|
+
hash: -385783123591010547
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
none: false
|
119
|
+
requirements:
|
120
|
+
- - ! '>='
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
requirements: []
|
124
|
+
rubyforge_project:
|
125
|
+
rubygems_version: 1.8.25
|
126
|
+
signing_key:
|
127
|
+
specification_version: 3
|
128
|
+
summary: Capistrano recipes for puma using runit and monit
|
129
|
+
test_files: []
|