kapify 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -29,6 +29,25 @@ before_fork do |server, worker|
29
29
  end
30
30
  end
31
31
 
32
+ # The following is only recommended for memory/DB-constrained
33
+ # installations. It is not needed if your system can house
34
+ # twice as many worker_processes as you have configured.
35
+ #
36
+ # # This allows a new master process to incrementally
37
+ # # phase out the old master process with SIGTTOU to avoid a
38
+ # # thundering herd (especially in the "preload_app false" case)
39
+ # # when doing a transparent upgrade. The last worker spawned
40
+ # # will then kill off the old master process with a SIGQUIT.
41
+
42
+ #old_pid = "#{server.config[:pid]}.oldbin"
43
+ #if old_pid != server.pid
44
+ #begin
45
+ ##sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU
46
+ #Process.kill(sig, File.read(old_pid).to_i)
47
+ #rescue Errno::ENOENT, Errno::ESRCH
48
+ #end
49
+ #end
50
+
32
51
  if defined?(Resque)
33
52
  Resque.redis.quit
34
53
  end
@@ -43,6 +62,6 @@ after_fork do |server, worker|
43
62
  end
44
63
 
45
64
  if defined?(Resque)
46
- Resque.redis = 'localhost:6379'
65
+ Resque.redis.client.reconnect
47
66
  end
48
67
  end
@@ -55,23 +55,58 @@ restart|reload)
55
55
  run "$CMD"
56
56
  ;;
57
57
  upgrade)
58
- if sig USR2 && sleep 2 && sig 0 && oldsig QUIT
58
+ if test -s $PID; then ORIG_PID=`cat $PID`; else ORIG_PID=0; fi
59
+
60
+ echo 'Original PID: ' $ORIG_PID
61
+
62
+ if sig USR2
59
63
  then
64
+ echo 'USR2 sent; Waiting for .oldbin'
60
65
  n=$TIMEOUT
61
- while test -s $OLD_PIN && test $n -ge 0
66
+
67
+ #wait for .oldpid to be written
68
+ while (!(test -s $OLD_PID) && test $n -ge 0)
69
+ do
70
+ printf '.' && sleep 1 && n=$(( $n - 1 ))
71
+ done
72
+
73
+ echo 'Waiting for new pid file'
74
+ #when this loop finishes, should have new pid file
75
+ while (!(test -s $PID ) || test -s $OLD_PID) && test $n -ge 0
62
76
  do
63
77
  printf '.' && sleep 1 && n=$(( $n - 1 ))
64
78
  done
79
+
80
+ if test -s $PID
81
+ then
82
+ NEW_PID=`cat $PID`
83
+ else
84
+ echo 'New master failed to start; see error log'
85
+ exit 1
86
+ fi
87
+
88
+ #timeout has elapsed, verify new pid file exists
89
+ if [ $ORIG_PID -eq $NEW_PID ]
90
+ then
91
+ echo
92
+ echo >&2 'New master failed to start; see error log'
93
+ exit 1
94
+ fi
95
+
96
+ echo 'New PID: ' $NEW_PID
97
+
98
+ #verify old master QUIT
65
99
  echo
66
-
67
- if test $n -lt 0 && test -s $OLD_PIN
100
+ if test -s $OLD_PID
68
101
  then
69
- echo >&2 "$OLD_PIN still exists after $TIMEOUT seconds"
102
+ echo >&2 "$OLD_PID still exists after $TIMEOUT seconds"
70
103
  exit 1
71
104
  fi
105
+
106
+ printf 'Unicorn successfully upgraded'
72
107
  exit 0
73
108
  fi
74
- echo >&2 "Couldn't upgrade, starting '$CMD' instead"
109
+ echo >&2 "Upgrade failed: executing '$CMD' "
75
110
  run "$CMD"
76
111
  ;;
77
112
  reopen-logs)
data/lib/kapify/base.rb CHANGED
@@ -41,4 +41,10 @@ Capistrano::Configuration.instance.load do
41
41
  put ERB.new(File.read(config_file)).result(binding), target
42
42
  end
43
43
 
44
+ def ask_with_default(prompt, default_value)
45
+ Capistrano::CLI.ui.ask(prompt) do |q|
46
+ q.default = default_value
47
+ q.answer_type = ->(res) { res.to_s }
48
+ end
49
+ end
44
50
  end
@@ -1,3 +1,3 @@
1
1
  module Kapify
2
- VERSION = "0.0.11"
2
+ VERSION = "0.0.12"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kapify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
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-05-24 00:00:00.000000000 Z
12
+ date: 2013-05-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capistrano
@@ -106,7 +106,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
106
106
  version: '0'
107
107
  segments:
108
108
  - 0
109
- hash: -4017653492412988607
109
+ hash: -3028142537426582318
110
110
  required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  none: false
112
112
  requirements:
@@ -115,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  version: '0'
116
116
  segments:
117
117
  - 0
118
- hash: -4017653492412988607
118
+ hash: -3028142537426582318
119
119
  requirements: []
120
120
  rubyforge_project:
121
121
  rubygems_version: 1.8.23