simple-capistrano-unicorn 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +2 -0
- data/README.md +2 -1
- data/lib/simple-capistrano-unicorn/namespace.rb +9 -7
- data/lib/simple-capistrano-unicorn/version.rb +1 -1
- metadata +3 -3
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -69,4 +69,5 @@ You can customize the gems behavior by setting any (or all) of the following opt
|
|
69
69
|
* `unicorn_config` the path to the unicorn config file. Defaults to `"#{current_path}/config/unicorn.rb"`.
|
70
70
|
* `unicorn_log` the path where unicorn places its STDERR-log. Defaults to `"#{shared_path}/log/unicorn.stderr.log"`.
|
71
71
|
* `use_bundler` defines whether Unicorn should start with `bundle exec` or not. Default to `true`.
|
72
|
-
* `rails_env` sets the environment that the server will run in. Defaults to `"production"`.
|
72
|
+
* `rails_env` sets the environment that the server will run in. Defaults to `"production"`.
|
73
|
+
* `unicorn_command` lets you specify the Unicorn command if you want to use `unicorn_rails`. Defaults to `"unicorn"`.
|
@@ -12,9 +12,10 @@ module SimpleCapistranoUnicorn
|
|
12
12
|
_cset(:unicorn_log) { "#{shared_path}/log/unicorn.stderr.log" }
|
13
13
|
_cset(:use_bundler) { true }
|
14
14
|
_cset(:rails_env) { "production" }
|
15
|
+
_cset(:unicorn_command) { "unicorn" }
|
15
16
|
|
16
17
|
def process_running?(server, pidfile)
|
17
|
-
cmd = "if [ -e #{
|
18
|
+
cmd = "if [ -e #{pidfile} ]; then ps cax | grep `cat #{pidfile}` > /dev/null; if [ $? -eq 0 ]; then echo -n running; fi; fi"
|
18
19
|
'running' == capture(cmd, :hosts => [server])
|
19
20
|
end
|
20
21
|
|
@@ -35,12 +36,12 @@ module SimpleCapistranoUnicorn
|
|
35
36
|
end
|
36
37
|
|
37
38
|
def start_unicorn(server)
|
38
|
-
run "cd #{current_path}; #{'bundle exec' if use_bundler}
|
39
|
+
run "cd #{current_path}; #{'bundle exec' if use_bundler} #{unicorn_command} -c #{unicorn_config} -E #{rails_env} -D", :hosts => [server]
|
39
40
|
end
|
40
41
|
|
41
42
|
def clean_old_unicorn(server)
|
42
43
|
if old_unicorn_is_running?(server)
|
43
|
-
run "kill -s QUIT `cat #{unicorn_old_pid}
|
44
|
+
run "if [ -e #{unicorn_old_pid} ]; then kill -s QUIT `cat #{unicorn_old_pid}`; fi", :hosts => [server]
|
44
45
|
run "if [ -e #{unicorn_old_pid} ]; then rm #{unicorn_old_pid}; fi", :hosts => [server]
|
45
46
|
logger.info nice_output("Cleaned up old Unicorn", server)
|
46
47
|
end
|
@@ -71,7 +72,7 @@ module SimpleCapistranoUnicorn
|
|
71
72
|
task :stop, :roles => :app do
|
72
73
|
find_servers(:roles => :app).each do |server|
|
73
74
|
if unicorn_is_running?(server)
|
74
|
-
run "kill -s QUIT `cat #{unicorn_pid}
|
75
|
+
run "if [ -e #{unicorn_pid} ]; then kill -s QUIT `cat #{unicorn_pid}`; fi", :hosts => [server]
|
75
76
|
run "if [ -e #{unicorn_pid} ]; then rm #{unicorn_pid}; fi", :hosts => [server]
|
76
77
|
logger.info nice_output("Stopped Unicorn!", server)
|
77
78
|
else
|
@@ -89,12 +90,13 @@ module SimpleCapistranoUnicorn
|
|
89
90
|
if unicorn_is_running?(server)
|
90
91
|
pid = capture "cat #{unicorn_pid}", :hosts => [server]
|
91
92
|
run "kill -s USR2 #{pid.to_i}", :hosts => [server] if pid.to_i > 0
|
92
|
-
sleep(
|
93
|
-
clean_old_unicorn(server)
|
93
|
+
sleep(5)
|
94
94
|
logger.info nice_output("Restarted Unicorn!", server)
|
95
|
+
clean_old_unicorn(server)
|
95
96
|
else
|
97
|
+
logger.info nice_output("Unicorn wasn't running, starting it!", server)
|
96
98
|
start_unicorn(server)
|
97
|
-
logger.info nice_output("Unicorn
|
99
|
+
logger.info nice_output("Started Unicorn!", server)
|
98
100
|
end
|
99
101
|
end
|
100
102
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple-capistrano-unicorn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -96,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
96
|
version: '0'
|
97
97
|
requirements: []
|
98
98
|
rubyforge_project: simple-capistrano-unicorn
|
99
|
-
rubygems_version: 1.8.
|
99
|
+
rubygems_version: 1.8.23
|
100
100
|
signing_key:
|
101
101
|
specification_version: 3
|
102
102
|
summary: Contains a collection of simple tasks to manage Unicorn with Capistrano.
|