capistrano-unicorn 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -0
- data/lib/capistrano-unicorn/capistrano_integration.rb +29 -4
- data/lib/capistrano-unicorn/version.rb +1 -1
- metadata +5 -4
data/Rakefile
ADDED
@@ -11,6 +11,12 @@ module CapistranoUnicorn
|
|
11
11
|
def remote_file_exists?(full_path)
|
12
12
|
'true' == capture("if [ -e #{full_path} ]; then echo 'true'; fi").strip
|
13
13
|
end
|
14
|
+
|
15
|
+
# Check if process is running
|
16
|
+
#
|
17
|
+
def process_exists?(pid_file)
|
18
|
+
capture("ps -p $(cat #{pid_file}) ; true").strip.split("\n").size == 2
|
19
|
+
end
|
14
20
|
|
15
21
|
# Set unicorn vars
|
16
22
|
#
|
@@ -21,6 +27,15 @@ module CapistranoUnicorn
|
|
21
27
|
namespace :unicorn do
|
22
28
|
desc 'Start Unicorn'
|
23
29
|
task :start, :roles => :app, :except => {:no_release => true} do
|
30
|
+
if remote_file_exists?(unicorn_pid)
|
31
|
+
if process_exists?(unicorn_pid)
|
32
|
+
logger.important("Unicorn is already running!", "Unicorn")
|
33
|
+
next
|
34
|
+
else
|
35
|
+
run "rm #{unicorn_pid}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
24
39
|
config_path = "#{current_path}/config/unicorn/#{unicorn_env}.rb"
|
25
40
|
if remote_file_exists?(config_path)
|
26
41
|
logger.important("Starting...", "Unicorn")
|
@@ -33,8 +48,13 @@ module CapistranoUnicorn
|
|
33
48
|
desc 'Stop Unicorn'
|
34
49
|
task :stop, :roles => :app, :except => {:no_release => true} do
|
35
50
|
if remote_file_exists?(unicorn_pid)
|
36
|
-
|
37
|
-
|
51
|
+
if process_exists?(unicorn_pid)
|
52
|
+
logger.important("Stopping...", "Unicorn")
|
53
|
+
run "#{try_sudo} kill `cat #{unicorn_pid}`"
|
54
|
+
else
|
55
|
+
run "rm #{unicorn_pid}"
|
56
|
+
logger.important("Unicorn is not running.", "Unicorn")
|
57
|
+
end
|
38
58
|
else
|
39
59
|
logger.important("No PIDs found. Check if unicorn is running.", "Unicorn")
|
40
60
|
end
|
@@ -43,8 +63,13 @@ module CapistranoUnicorn
|
|
43
63
|
desc 'Unicorn graceful shutdown'
|
44
64
|
task :graceful_stop, :roles => :app, :except => {:no_release => true} do
|
45
65
|
if remote_file_exists?(unicorn_pid)
|
46
|
-
|
47
|
-
|
66
|
+
if process_exists?(unicorn_pid)
|
67
|
+
logger.important("Stopping...", "Unicorn")
|
68
|
+
run "#{try_sudo} kill -s QUIT `cat #{unicorn_pid}`"
|
69
|
+
else
|
70
|
+
run "rm #{unicorn_pid}"
|
71
|
+
logger.important("Unicorn is not running.", "Unicorn")
|
72
|
+
end
|
48
73
|
else
|
49
74
|
logger.important("No PIDs found. Check if unicorn is running.", "Unicorn")
|
50
75
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-unicorn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-02-04 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capistrano
|
16
|
-
requirement: &
|
16
|
+
requirement: &2165055020 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2165055020
|
25
25
|
description: Capistrano plugin that integrates Unicorn server tasks.
|
26
26
|
email: dan.sosedoff@gmail.com
|
27
27
|
executables: []
|
@@ -31,6 +31,7 @@ files:
|
|
31
31
|
- .gitignore
|
32
32
|
- Gemfile
|
33
33
|
- README.md
|
34
|
+
- Rakefile
|
34
35
|
- capistrano-unicorn.gemspec
|
35
36
|
- examples/rails3.rb
|
36
37
|
- lib/capistrano-unicorn.rb
|