capistrano3-puma 0.2.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +8 -3
- data/capistrano-puma.gemspec +1 -0
- data/capistrano3-puma.gemspec +1 -0
- data/lib/capistrano/puma/version.rb +1 -1
- data/lib/capistrano/puma/workers.rb +2 -0
- data/lib/capistrano/tasks/jungle.cap +5 -5
- data/lib/capistrano/tasks/puma.cap +29 -6
- data/lib/capistrano/tasks/workers.cap +34 -0
- data/lib/capistrano/templates/puma-rpm.erb +1 -1
- data/lib/capistrano/templates/puma.rb.erb +5 -0
- metadata +19 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48c6297166ac6479aff3f05e5a0ed5b14914d7cd
|
4
|
+
data.tar.gz: 2c7dc35a0fdae21d452184d2fa015e56ed6ebbf4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0553ef2f9236710b405c83831345caf4c32b73fb990ff25079c8d1b27e722c2fb5063c301ef079848d4fbe11209c0c5b48bc3210398e13f25b420215a64b2901
|
7
|
+
data.tar.gz: 7c9848e750ab5774ef1d47a46143bc71c1aa82d23ccd4949d64e087cecacaf4f9a51a9c9c92e1d2735914e38971f7553d44feeb4d161e6282b35d2b4ba80f5a6
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# Capistrano::Puma
|
2
2
|
|
3
|
-
In the current version the gem will expect a puma.rb in the shared directory, if it does not find puma.rb in the expected place it will automatically generate one with sane defaults. Keep in mind this means a puma.rb in the config directory or subdirectories will be ignored. During preparation for deployment you must start the process initially with bundle exec cap $stage puma:start , after starting the process bundle exec cap $stage deploy will work without hanging. The need to start the process initially will be addressed in a future release.
|
4
|
-
|
5
3
|
## Installation
|
6
4
|
|
7
5
|
Add this line to your application's Gemfile:
|
@@ -21,6 +19,7 @@ And then execute:
|
|
21
19
|
# Capfile
|
22
20
|
|
23
21
|
require 'capistrano/puma'
|
22
|
+
require 'capistrano/puma/workers' #if you want to control the workers (in cluster mode)
|
24
23
|
require 'capistrano/puma/jungle' #if you need the jungle tasks
|
25
24
|
require 'capistrano/puma/monit' #if you need the monit tasks
|
26
25
|
```
|
@@ -29,6 +28,7 @@ And then execute:
|
|
29
28
|
Configurable options, shown here with defaults: Please note the configuration options below are not required unless you are trying to override a default setting, for instance if you are deploying on a host on which you do not have sudo or root privileges and you need to restrict the path. These settings go in the deploy.rb file.
|
30
29
|
|
31
30
|
```ruby
|
31
|
+
set :puma_rackup, -> { File.join(current_path, 'config.ru') }
|
32
32
|
set :puma_state, "#{shared_path}/tmp/pids/puma.state"
|
33
33
|
set :puma_pid, "#{shared_path}/tmp/pids/puma.pid"
|
34
34
|
set :puma_bind, "unix://#{shared_path}/tmp/sockets/puma.sock"
|
@@ -52,6 +52,12 @@ Ensure that the following directories are shared (via ``linked_dirs``):
|
|
52
52
|
tmp/pids tmp/sockets log
|
53
53
|
|
54
54
|
## Changelog
|
55
|
+
- 0.3.5: Fixed a prehistoric bug
|
56
|
+
- 0.3.4: I don't remember what i did here
|
57
|
+
- 0.3.3: Puma jungle start fix
|
58
|
+
- 0.3.2: Tag option support (require puma 2.8.2+)
|
59
|
+
- 0.3.1: Typo fix
|
60
|
+
- 0.3.0: Initial support for puma signals
|
55
61
|
- 0.2.2: Application pre-loading is optional now (set puma_preload_app to false to turn it off)
|
56
62
|
- 0.2.1: Tasks are run within rack context
|
57
63
|
- 0.2.0: Support for puma `ActiveRecord::Base.establish_connection` on
|
@@ -65,7 +71,6 @@ Ensure that the following directories are shared (via ``linked_dirs``):
|
|
65
71
|
- 0.0.7: Gem pushed to rubygems as capistrano3-puma. Support of Redhat based OS for Jungle init script.
|
66
72
|
|
67
73
|
## TODO
|
68
|
-
- Support to https://github.com/puma/puma/pull/399 with puma:workers:more, puma:workers:less
|
69
74
|
|
70
75
|
## Contributors
|
71
76
|
|
data/capistrano-puma.gemspec
CHANGED
data/capistrano3-puma.gemspec
CHANGED
@@ -16,12 +16,12 @@ namespace :puma do
|
|
16
16
|
template_puma 'run-puma', "#{fetch(:tmp_dir)}/run-puma", role
|
17
17
|
execute "chmod +x #{fetch(:tmp_dir)}/run-puma"
|
18
18
|
sudo "mv #{fetch(:tmp_dir)}/run-puma #{fetch(:puma_run_path)}"
|
19
|
-
if test '[ -f /etc/
|
20
|
-
#Debian flavor OS
|
21
|
-
debian_install
|
22
|
-
elsif test '[ -f /etc/redhat-release ]'
|
19
|
+
if test '[ -f /etc/redhat-release ]'
|
23
20
|
#RHEL flavor OS
|
24
21
|
rhel_install
|
22
|
+
elsif test '[ -f /etc/lsb-release ]'
|
23
|
+
#Debian flavor OS
|
24
|
+
debian_install
|
25
25
|
else
|
26
26
|
#Some other OS
|
27
27
|
error 'This task is not supported for your OS'
|
@@ -72,7 +72,7 @@ namespace :puma do
|
|
72
72
|
desc "#{command} puma"
|
73
73
|
task command do
|
74
74
|
on roles(fetch(:puma_role)) do
|
75
|
-
sudo "service puma #{command}
|
75
|
+
sudo "service puma #{command} app=#{current_path}"
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
@@ -1,11 +1,12 @@
|
|
1
1
|
namespace :load do
|
2
2
|
task :defaults do
|
3
3
|
set :puma_role, :app
|
4
|
-
set :puma_env, -> { fetch(:rack_env, fetch(:rails_env,
|
4
|
+
set :puma_env, -> { fetch(:rack_env, fetch(:rails_env, fetch(:stage))) }
|
5
5
|
# Configure "min" to be the minimum number of threads to use to answer
|
6
6
|
# requests and "max" the maximum.
|
7
7
|
set :puma_threads, [0, 16]
|
8
8
|
set :puma_workers, 0
|
9
|
+
set :puma_rackup, -> { File.join(current_path, 'config.ru') }
|
9
10
|
set :puma_state, -> { File.join(shared_path, 'tmp', 'pids', 'puma.state') }
|
10
11
|
set :puma_pid, -> { File.join(shared_path, 'tmp', 'pids', 'puma.pid') }
|
11
12
|
set :puma_bind, -> { File.join('unix://', shared_path, 'tmp', 'sockets', 'puma.sock') }
|
@@ -35,27 +36,37 @@ namespace :puma do
|
|
35
36
|
on roles (fetch(:puma_role)) do
|
36
37
|
within current_path do
|
37
38
|
with rack_env: fetch(:puma_env) do
|
39
|
+
|
38
40
|
execute :bundle, 'exec', :puma, "-C #{fetch(:puma_conf)}"
|
39
41
|
end
|
40
42
|
end
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
44
|
-
%w[halt stop status].
|
46
|
+
%w[halt stop status].map do |command|
|
45
47
|
desc "#{command} puma"
|
46
48
|
task command do
|
47
49
|
on roles (fetch(:puma_role)) do
|
48
50
|
within current_path do
|
49
51
|
with rack_env: fetch(:puma_env) do
|
50
|
-
|
52
|
+
if test "[ -f #{fetch(:puma_pid)} ]"
|
53
|
+
if test "kill -0 $( cat #{fetch(:puma_pid)} )"
|
54
|
+
execute :bundle, 'exec', :pumactl, "-S #{fetch(:puma_state)} #{command}"
|
55
|
+
else
|
56
|
+
# delete invalid pid file , process is not running.
|
57
|
+
execute :rm, fetch(:puma_pid)
|
58
|
+
end
|
59
|
+
else
|
60
|
+
#pid file not found, so puma is probably not running or it using another pidfile
|
61
|
+
warn 'Puma not running'
|
62
|
+
end
|
51
63
|
end
|
52
64
|
end
|
53
65
|
end
|
54
66
|
end
|
55
67
|
end
|
56
68
|
|
57
|
-
|
58
|
-
%w[phased-restart restart].each do |command|
|
69
|
+
%w[phased-restart restart].map do |command|
|
59
70
|
desc "#{command} puma"
|
60
71
|
task command do
|
61
72
|
on roles (fetch(:puma_role)) do
|
@@ -74,7 +85,6 @@ namespace :puma do
|
|
74
85
|
end
|
75
86
|
end
|
76
87
|
|
77
|
-
|
78
88
|
task :check do
|
79
89
|
on roles (fetch(:puma_role)) do |role|
|
80
90
|
#Create puma.rb for new deployments
|
@@ -97,10 +107,23 @@ namespace :puma do
|
|
97
107
|
end
|
98
108
|
after 'deploy:finished', 'puma:smart_restart'
|
99
109
|
|
110
|
+
|
100
111
|
def puma_workers
|
101
112
|
fetch(:puma_workers) || 0
|
102
113
|
end
|
103
114
|
|
115
|
+
def puma_tag
|
116
|
+
if fetch(:puma_tag)
|
117
|
+
# Versions(puma) prior to 2.8.2 don't support tag option
|
118
|
+
if Gem.loaded_specs['puma'].version >= Gem::Version.new('2.8.2')
|
119
|
+
return "tag '#{fetch(:puma_tag)}'"
|
120
|
+
else
|
121
|
+
warn 'Version puma 2.8.2+ required for tag option: Tag not set'
|
122
|
+
end
|
123
|
+
return
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
104
127
|
def template_puma(from, to, role)
|
105
128
|
[
|
106
129
|
"lib/capistrano/templates/#{from}-#{role.hostname}-#{fetch(:stage)}.rb",
|
@@ -0,0 +1,34 @@
|
|
1
|
+
namespace :puma do
|
2
|
+
namespace :workers do
|
3
|
+
desc 'Add a worker'
|
4
|
+
task :count do
|
5
|
+
on roles (fetch(:puma_role)) do
|
6
|
+
#TODO
|
7
|
+
# cleanup
|
8
|
+
# add host name/ip
|
9
|
+
workers_count = capture("ps ax | grep -c 'puma: cluster worker: `cat #{fetch(:puma_pid)}`'").to_i - 1
|
10
|
+
log "Workers count : #{workers_count}"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# TODO
|
15
|
+
# Add/remove workers to specific host/s
|
16
|
+
# Define # of workers to add/remove
|
17
|
+
# Refractor
|
18
|
+
desc 'Worker++'
|
19
|
+
task :more do
|
20
|
+
on roles (fetch(:puma_role)) do
|
21
|
+
execute("kill -TTIN `cat #{fetch(:puma_pid)}`")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
desc 'Worker--'
|
26
|
+
task :less do
|
27
|
+
on roles (fetch(:puma_role)) do
|
28
|
+
execute("kill -TTOU `cat #{fetch(:puma_pid)}`")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
@@ -131,7 +131,7 @@ do_restart_one() {
|
|
131
131
|
dir=`echo $i | cut -d , -f 1`
|
132
132
|
if [ -e $PIDFILE ]; then
|
133
133
|
log_daemon_msg "--> About to restart puma $1"
|
134
|
-
pumactl --state $dir/tmp/
|
134
|
+
pumactl --state $dir/tmp/pids/puma.state restart
|
135
135
|
|
136
136
|
else
|
137
137
|
log_daemon_msg "--> Your puma was never playing... Let's get it out there first"
|
@@ -1,14 +1,19 @@
|
|
1
1
|
#!/usr/bin/env puma
|
2
2
|
|
3
3
|
directory '<%= current_path %>'
|
4
|
+
rackup "<%=fetch(:puma_rackup)%>"
|
4
5
|
environment '<%= fetch(:puma_env) %>'
|
6
|
+
<%= puma_tag %>
|
5
7
|
daemonize true
|
6
8
|
pidfile "<%=fetch(:puma_pid)%>"
|
7
9
|
state_path "<%=fetch(:puma_state)%>"
|
8
10
|
stdout_redirect '<%=fetch(:puma_access_log)%>', '<%=fetch(:puma_error_log)%>', true
|
11
|
+
|
12
|
+
|
9
13
|
threads <%=fetch(:puma_threads).join(',')%>
|
10
14
|
bind "<%=fetch(:puma_bind)%>"
|
11
15
|
|
16
|
+
|
12
17
|
workers <%= puma_workers %>
|
13
18
|
<% if fetch(:puma_preload_app) %>
|
14
19
|
preload_app!
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano3-puma
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Abdelkader Boudih
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: puma
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
description: Puma integration for Capistrano 3
|
28
42
|
email:
|
29
43
|
- Terminale@gmail.com
|
@@ -43,9 +57,11 @@ files:
|
|
43
57
|
- lib/capistrano/puma/jungle.rb
|
44
58
|
- lib/capistrano/puma/monit.rb
|
45
59
|
- lib/capistrano/puma/version.rb
|
60
|
+
- lib/capistrano/puma/workers.rb
|
46
61
|
- lib/capistrano/tasks/jungle.cap
|
47
62
|
- lib/capistrano/tasks/monit.cap
|
48
63
|
- lib/capistrano/tasks/puma.cap
|
64
|
+
- lib/capistrano/tasks/workers.cap
|
49
65
|
- lib/capistrano/templates/puma-deb.erb
|
50
66
|
- lib/capistrano/templates/puma-rpm.erb
|
51
67
|
- lib/capistrano/templates/puma.rb.erb
|
@@ -71,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
87
|
version: '0'
|
72
88
|
requirements: []
|
73
89
|
rubyforge_project:
|
74
|
-
rubygems_version: 2.
|
90
|
+
rubygems_version: 2.2.2
|
75
91
|
signing_key:
|
76
92
|
specification_version: 4
|
77
93
|
summary: Puma integration for Capistrano
|