capistrano-unicorn-edge 0.1.5 → 0.1.6
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/README.md +8 -10
- data/capistrano-unicorn-edge.gemspec +1 -1
- data/examples/unicorn.rb +6 -0
- data/lib/capistrano/tasks/unicorn.cap +18 -18
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b50eaf0a41c3a3f1ec77b0eab2a72cee477b85ac
|
4
|
+
data.tar.gz: 1060be56f977c9f5e068a355fc10119300e37fed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c8f6d1fc296293373bb9858eda9162283504ecf5a9b83f503560df016f52f46a4bde0492dcf74cb28169c1376054e18e8c42bf0273cb2e5bddfa210bcd48dc9
|
7
|
+
data.tar.gz: 7cc64f66c0e4f16587fb434ad33acfbb3edc8bc105f78f0e48f70b0f70c2f212aefcd91a079365393b156f0a0c08142f5cf87158c4b1846e25e22273dbd2baa7
|
data/README.md
CHANGED
@@ -7,11 +7,11 @@ cap unicorn:start # Start unicorn
|
|
7
7
|
cap unicorn:stop # Stop unicorn gracefully (QUIT)
|
8
8
|
cap unicorn:shutdown # Stop unicorn immediately (TERM)
|
9
9
|
cap unicorn:restart # Restart unicorn
|
10
|
+
cat unicorn:restart_quit # Restart unicorn, simple stop it gracefully and start again (QUIT)
|
11
|
+
cat unicorn:restart_term # Restart unicorn, simple stop it immediately and start it again (TERM)
|
10
12
|
cap unicorn:restart_hup # Restart unicorn, when preload_app is false (HUP)
|
11
13
|
cap unicorn:restart_usr2 # Restart unicorn, when before_fork hook is set and preload_app is true (USR2)
|
12
14
|
cap unicorn:restart_usr2_quit # Restart unicorn, when before_fork hook is not set and preload_app is true (USR2 + QUIT)
|
13
|
-
cat unicorn:restart_quit # Restart unicorn, simple stop it gracefully and start again (QUIT)
|
14
|
-
cat unicorn:restart_term # Restart unicorn, simple stop it immediately and start it again (TERM)
|
15
15
|
cap unicorn:add_worker[count] # Add a worker (TTIN)
|
16
16
|
cap unicorn:remove_worker[count] # Remove a worker (TTOU)
|
17
17
|
cap unicorn:stop_workers # Stop all workers but keep the master running (WINCH)
|
@@ -51,19 +51,17 @@ set :unicorn_roles, :app # this is default
|
|
51
51
|
set :unicorn_options, '' # this is default
|
52
52
|
set :unicorn_restart_delay, 5 # this is default
|
53
53
|
set :unicorn_rack_env, :deployment # this is default
|
54
|
-
set :unicorn_restart_method, :
|
54
|
+
set :unicorn_restart_method, :restart_quit # this is default
|
55
55
|
```
|
56
56
|
|
57
|
-
|
58
|
-
|
59
|
-
There are three different ways to restart server:
|
60
|
-
* `:restart_hup` restarts all workers and therefore all code changes, makes sense if `preload_app` is false
|
61
|
-
* `:restart_usr2_quit` re-executes the running binary and stops previous instance in `:unicorn_restart_delay`
|
62
|
-
* `:restart_usr2` the same as above but `before_fork` hook has to be set, default and the best choice
|
57
|
+
There are five different ways to restart server:
|
63
58
|
* `:restart_quit` stops server gracefully and starts it again in `:unicorn_restart_delay`
|
64
59
|
* `:restart_term` stops server immediately and starts it again
|
60
|
+
* `:restart_hup` restarts all workers and therefore all code changes, makes sense if `preload_app` is false
|
61
|
+
* `:restart_usr2` the same as above but `before_fork` hook has to be set, see an example `examples/unicorn.rb`
|
62
|
+
* `:restart_usr2_quit` re-executes the running binary and stops previous instance in `:unicorn_restart_delay`
|
65
63
|
|
66
|
-
|
64
|
+
`USR2` signal based methods give you zero-downtime deployments but I've run into one trouble when environment changes (e.g. in `/etc/environment`) aren't updated because new instance is spawned by the old one, unfortunately it can be solved only by re-logining and starting a new instance (`restart_quit` does the stuff).
|
67
65
|
|
68
66
|
## Contributing
|
69
67
|
|
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "capistrano-unicorn-edge"
|
7
|
-
spec.version = "0.1.
|
7
|
+
spec.version = "0.1.6"
|
8
8
|
spec.authors = ["Alexander Menzhinsky"]
|
9
9
|
spec.email = ["amenzhinsky@gmail.com"]
|
10
10
|
spec.summary = %q{Unicorn support for Capistrano 3.x}
|
data/examples/unicorn.rb
CHANGED
@@ -24,6 +24,12 @@ stdout_path "#{app_path}/log/unicorn.log"
|
|
24
24
|
pid "#{app_path}/tmp/pids/unicorn.pid"
|
25
25
|
|
26
26
|
before_fork do |server, worker|
|
27
|
+
# Using Capistrano, the path to the Gemfile is stored with release
|
28
|
+
# timestamp in the path, rather than the current symlink.
|
29
|
+
unless ENV['BUNDLE_GEMFILE']
|
30
|
+
ENV['BUNDLE_GEMFILE'] = "#{app_path}/Gemfile"
|
31
|
+
end
|
32
|
+
|
27
33
|
##
|
28
34
|
# When sent a USR2, Unicorn will suffix its pidfile with .oldbin and
|
29
35
|
# immediately start loading up a new version of itself (loaded with a new
|
@@ -25,6 +25,23 @@ namespace :unicorn do
|
|
25
25
|
invoke "unicorn:#{fetch(:unicorn_restart_method)}"
|
26
26
|
end
|
27
27
|
|
28
|
+
desc 'Restart unicorn, simple stop it gracefully and start again (QUIT)'
|
29
|
+
task :restart_quit do
|
30
|
+
on roles(fetch(:unicorn_roles)) do
|
31
|
+
unicorn_send_signal(:QUIT) if unicorn_is_running?
|
32
|
+
execute :sleep, fetch(:unicorn_restart_delay)
|
33
|
+
unicorn_start
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
desc 'Restart unicorn, simple stop it immediately and start it again (TERM)'
|
38
|
+
task :restart_term do
|
39
|
+
on roles(fetch(:unicorn_roles)) do
|
40
|
+
unicorn_send_signal(:TERM) if unicorn_is_running?
|
41
|
+
unicorn_start
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
28
45
|
desc 'Restart unicorn, when preload_app is false (HUP)'
|
29
46
|
task :restart_hup do
|
30
47
|
on roles(fetch(:unicorn_roles)) do
|
@@ -64,23 +81,6 @@ namespace :unicorn do
|
|
64
81
|
end
|
65
82
|
end
|
66
83
|
|
67
|
-
desc 'Restart unicorn, simple stop it gracefully and start again (QUIT)'
|
68
|
-
task :restart_quit do
|
69
|
-
on roles(fetch(:unicorn_roles)) do
|
70
|
-
unicorn_send_signal(:QUIT) if unicorn_is_running?
|
71
|
-
execute :sleep, fetch(:unicorn_restart_delay)
|
72
|
-
unicorn_start
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
desc 'Restart unicorn, simple stop it immediately and start it again (TERM)'
|
77
|
-
task :restart_term do
|
78
|
-
on roles(fetch(:unicorn_roles)) do
|
79
|
-
unicorn_send_signal(:TERM) if unicorn_is_running?
|
80
|
-
unicorn_start
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
84
|
desc 'Add a worker (TTIN)'
|
85
85
|
task :add_worker, :count do |_, args|
|
86
86
|
on roles(fetch(:unicorn_roles)) do
|
@@ -134,7 +134,7 @@ namespace :load do
|
|
134
134
|
set :unicorn_options, ''
|
135
135
|
set :unicorn_restart_delay, 5
|
136
136
|
set :unicorn_rack_env, :deployment
|
137
|
-
set :unicorn_restart_method, :
|
137
|
+
set :unicorn_restart_method, :restart_quit
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-unicorn-edge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Menzhinsky
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|