app-deploy 0.6.0 → 0.7.0

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.
data/CHANGES CHANGED
@@ -1,5 +1,45 @@
1
1
  = app-deploy changes history
2
2
 
3
+ == app-deploy 0.7.0 / 2009-12-16
4
+ * pid management rewritten
5
+ * added signal tasks to deal with any pidfile process
6
+ * switched nginx tasks to use signal tasks as a backend
7
+ * added unicorn tasks just like the way nginx worked
8
+
9
+ http://blogger.godfat.org/2009/12/app-deploy-released-2.html
10
+
11
+ i hate myself... (that always do stupid things)
12
+
13
+ i would prepare to release app-deploy-0.7.0 tomorrow,
14
+ after some simple testings with the new nginx tasks
15
+ and unicorn tasks, which wrapping signal tasks to
16
+ manage processes with a pid file.
17
+
18
+ there's no much difference between nginx tasks and
19
+ unicorn tasks. to name a few, the process name,
20
+ config path, and pid path. (plus a ENV option for rack/rails)
21
+
22
+ that is, rake $ (-- is this Haskell favor i suppose? i mean, $)
23
+ app:signal:start # => start a process unless pid file existed
24
+ app:signal:stop # => send TERM to a process, ignore all errors
25
+ app:signal:restart # => stop + start
26
+ app:singal:reload # => same as stop, but send HUP instead
27
+ app:singal:kill # send any signal as your wish
28
+
29
+ then i would start migrating all services from passenger
30
+ to unicorn afterward as i promised to Eric Wong.
31
+
32
+ *
33
+
34
+ mogilefs-client and unicorn are both well written.
35
+ i'm an old fogey with large fonts too :p
36
+ there are so many websites with horrible layouts on
37
+ my browsers... especially on safari. firefox is a bit
38
+ better about this. (words won't get overlapped sometimes)
39
+
40
+ i should try to learn some styles from those two libs.
41
+ and ramaze and innate, i guess.
42
+
3
43
  == app-deploy 0.6.0 / 2009-12-14
4
44
  * first release to gemcutter
5
45
 
data/README CHANGED
@@ -1,4 +1,4 @@
1
- = app-deploy 0.6
1
+ = app-deploy 0.7
2
2
  by Lin Jen-Shin (aka godfat-真常[http://godfat.org])
3
3
  godfat (XD) godfat.org
4
4
 
@@ -13,7 +13,7 @@ by Lin Jen-Shin (aka godfat-真常[http://godfat.org])
13
13
  == FEATURES:
14
14
 
15
15
  $ rake -T app
16
- (in /home/photos)
16
+ (in /Users/godfat/project/godfat/app-deploy)
17
17
  rake app:daemon:restart[config] # restart the daemon cluster
18
18
  rake app:daemon:start[config] # start the daemon cluster
19
19
  rake app:daemon:stop[config] # stop the daemon cluster
@@ -36,14 +36,25 @@ rake app:install:remote:setup[user,file,hosts,script] # upload a tarball and un
36
36
  rake app:install:remote:sh[hosts,script] # invoke a shell script on remote machines
37
37
  rake app:install:remote:upload[file,hosts,path] # upload a file to remote machines
38
38
  rake app:install:remote:useradd[user,hosts,script] # create a user on remote machines
39
+ rake app:nginx:kill[signal] # send a signal to nginx
39
40
  rake app:nginx:reload # reload config
40
- rake app:nginx:restart # restart nginx
41
- rake app:nginx:start[config,nginx] # start nginx, default config is config/nginx.conf, nginx is /usr/sbin/nginx
41
+ rake app:nginx:restart[config,nginx,timeout] # restart nginx
42
+ rake app:nginx:start[config,nginx] # start nginx, default config is config/nginx.conf
42
43
  rake app:nginx:stop[timeout] # stop nginx
43
44
  rake app:rack:restart[config] # restart the rack cluster
44
45
  rake app:rack:start[config] # start the rack cluster
45
46
  rake app:rack:stop[config] # stop the rack cluster
46
47
  rake app:server:restart # please define your server:restart task
48
+ rake app:signal:kill[signal,pidfile,name] # send a signal to a process with a pidfile
49
+ rake app:signal:reload[pidfile,name] # send HUP to a process with a pidfile
50
+ rake app:signal:restart[script,pidfile,timeout,name] # restart a process with a pidfile
51
+ rake app:signal:start[script,pidfile] # execute a script if pidfile is not existed
52
+ rake app:signal:stop[pidfile,timeout,name] # terminate a process with a pidfile
53
+ rake app:unicorn:kill[signal] # send a signal to unicorn
54
+ rake app:unicorn:reload # reload config
55
+ rake app:unicorn:restart[config,env,unicorn,timeout] # restart unicorn
56
+ rake app:unicorn:start[config,env,unicorn] # start unicorn, default config is config/unicorn.rb
57
+ rake app:unicorn:stop[timeout] # stop unicorn
47
58
 
48
59
  == SYNOPSIS:
49
60
 
data/TODO CHANGED
@@ -1,9 +1,9 @@
1
1
  = app-deploy todo list
2
2
 
3
+ * please add test cases!!
4
+
3
5
  * adding sending signal to cluster
4
6
 
5
- * escape \" and \' in options?
6
- * extract rack-cluster
7
7
  * detect binding to port succeeded or not
8
8
  * fix default options for rack-cluster
9
9
 
data/app-deploy.gemspec CHANGED
@@ -2,33 +2,32 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{app-deploy}
5
- s.version = "0.5.0"
5
+ s.version = "0.6.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Lin Jen-Shin (a.k.a. godfat \347\234\237\345\270\270)"]
9
- s.date = %q{2009-02-09}
10
- s.description = %q{rake tasks for deployment}
8
+ s.authors = ["Lin Jen-Shin (aka godfat 真常)"]
9
+ s.date = %q{2009-12-16}
10
+ s.description = %q{ rake tasks for deployment}
11
11
  s.email = %q{godfat (XD) godfat.org}
12
- s.extra_rdoc_files = ["CHANGES", "README", "TODO", "app-deploy.gemspec", "example/daemon_cluster.yaml", "example/rack_cluster.yaml", "lib/app-deploy/daemon.rake", "lib/app-deploy/deploy.rake", "lib/app-deploy/gem.rake", "lib/app-deploy/git.rake", "lib/app-deploy/install.rake", "lib/app-deploy/merb.rake", "lib/app-deploy/mongrel.rake", "lib/app-deploy/nginx.rake", "lib/app-deploy/rack.rake", "lib/app-deploy/server.rake", "lib/app-deploy/thin.rake"]
13
- s.files = ["CHANGES", "README", "Rakefile", "TODO", "app-deploy.gemspec", "example/Rakefile", "example/daemon_cluster.yaml", "example/rack_cluster.yaml", "lib/app-deploy.rb", "lib/app-deploy/daemon.rake", "lib/app-deploy/daemon.rb", "lib/app-deploy/daemon_cluster.rb", "lib/app-deploy/deploy.rake", "lib/app-deploy/gem.rake", "lib/app-deploy/git.rake", "lib/app-deploy/install.rake", "lib/app-deploy/merb.rake", "lib/app-deploy/mongrel.rake", "lib/app-deploy/nginx.rake", "lib/app-deploy/rack.rake", "lib/app-deploy/rack_cluster.rb", "lib/app-deploy/server.rake", "lib/app-deploy/thin.rake", "lib/app-deploy/utils.rb", "lib/app-deploy/version.rb"]
14
- s.has_rdoc = true
12
+ s.extra_rdoc_files = ["CHANGES", "README", "Rakefile", "TODO", "app-deploy.gemspec", "example/Rakefile", "example/bin/install.sh", "example/bin/remote_install.sh", "example/bin/remote_update.sh", "example/bin/start.sh", "example/bin/update.sh", "example/daemon_cluster.yaml", "example/rack_cluster.yaml", "lib/app-deploy/daemon.rake", "lib/app-deploy/deploy.rake", "lib/app-deploy/deprecated/merb.rake", "lib/app-deploy/deprecated/mongrel.rake", "lib/app-deploy/gem.rake", "lib/app-deploy/git.rake", "lib/app-deploy/install.rake", "lib/app-deploy/nginx.rake", "lib/app-deploy/rack.rake", "lib/app-deploy/server.rake", "lib/app-deploy/signal.rake", "lib/app-deploy/thin.rake", "lib/app-deploy/unicorn.rake"]
13
+ s.files = ["CHANGES", "README", "Rakefile", "TODO", "app-deploy.gemspec", "example/Rakefile", "example/bin/install.sh", "example/bin/remote_install.sh", "example/bin/remote_update.sh", "example/bin/start.sh", "example/bin/update.sh", "example/daemon_cluster.yaml", "example/rack_cluster.yaml", "lib/app-deploy.rb", "lib/app-deploy/daemon.rake", "lib/app-deploy/daemon.rb", "lib/app-deploy/daemon_cluster.rb", "lib/app-deploy/deploy.rake", "lib/app-deploy/deprecated/merb.rake", "lib/app-deploy/deprecated/mongrel.rake", "lib/app-deploy/gem.rake", "lib/app-deploy/git.rake", "lib/app-deploy/install.rake", "lib/app-deploy/nginx.rake", "lib/app-deploy/rack.rake", "lib/app-deploy/rack_cluster.rb", "lib/app-deploy/server.rake", "lib/app-deploy/signal.rake", "lib/app-deploy/thin.rake", "lib/app-deploy/unicorn.rake", "lib/app-deploy/utils.rb", "lib/app-deploy/version.rb"]
15
14
  s.homepage = %q{http://github.com/godfat/app-deploy}
16
- s.rdoc_options = ["--diagram", "--charset=utf-8", "--inline-source", "--line-numbers", "--promiscuous", "--main", "README"]
15
+ s.rdoc_options = ["--main", "README"]
17
16
  s.require_paths = ["lib"]
18
- s.rubyforge_project = %q{ludy}
19
- s.rubygems_version = %q{1.3.1}
17
+ s.rubyforge_project = %q{app-deploy}
18
+ s.rubygems_version = %q{1.3.5}
20
19
  s.summary = %q{rake tasks for deployment}
21
20
 
22
21
  if s.respond_to? :specification_version then
23
22
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
24
- s.specification_version = 2
23
+ s.specification_version = 3
25
24
 
26
25
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
27
- s.add_development_dependency(%q<bones>, [">= 2.4.0"])
26
+ s.add_development_dependency(%q<bones>, [">= 3.2.0"])
28
27
  else
29
- s.add_dependency(%q<bones>, [">= 2.4.0"])
28
+ s.add_dependency(%q<bones>, [">= 3.2.0"])
30
29
  end
31
30
  else
32
- s.add_dependency(%q<bones>, [">= 2.4.0"])
31
+ s.add_dependency(%q<bones>, [">= 3.2.0"])
33
32
  end
34
33
  end
data/example/Rakefile CHANGED
@@ -4,20 +4,12 @@ begin
4
4
  rescue LoadError
5
5
  puts "app-deploy not found, automaticly downloading and installing..."
6
6
 
7
- gem_cmd = "#{Gem.ruby} #{`which gem`.strip}"
7
+ gem_cmd = "#{Gem.ruby} -S gem"
8
8
  gem_opt = '--user-install --no-ri --no-rdoc'
9
9
  gem_int = "#{gem_cmd} install #{gem_opt}"
10
10
 
11
- sh "#{gem_int} bones" # need bones to build app-deploy
11
+ sh "#{gem_int} app-deploy"
12
12
 
13
- sh 'git clone git://github.com/godfat/app-deploy.git app-deploy'
14
- Dir.chdir 'app-deploy'
15
-
16
- sh 'rake clobber'
17
- sh 'rake gem:package'
18
- sh "#{gem_int} --local pkg/app-deploy-*.gem"
19
-
20
- Dir.chdir '..'
21
13
  Gem.refresh
22
14
  require 'app-deploy'
23
15
  end
data/lib/app-deploy.rb CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- %w[ deploy gem git install nginx server rack daemon].each{ |task|
2
+ %w[ deploy gem git install server rack daemon signal nginx unicorn].each{ |task|
3
3
  load "app-deploy/#{task}.rake"
4
4
  }
5
5
 
@@ -2,30 +2,40 @@
2
2
  namespace :app do
3
3
  namespace :nginx do
4
4
 
5
- desc 'start nginx, default config is config/nginx.conf, nginx is /usr/sbin/nginx'
5
+ desc 'start nginx, default config is config/nginx.conf'
6
6
  task :start, [:config, :nginx] do |t, args|
7
- # TODO: extract pid file path
8
- if File.exist?('tmp/pids/nginx.pid')
9
- puts "WARN: pid file #{'tmp/pids/nginx.pid'} already exists, ignoring."
10
- else
11
- sh "#{args[:nginx] || '/usr/sbin/nginx'} -c #{args[:config] || 'config/nginx.conf'}"
12
- end
13
- end
14
-
15
- desc 'reload config'
16
- task :reload do
17
- # sh 'kill -HUP `cat tmp/pids/nginx.pid`'
18
- AppDeploy.hup('tmp/pids/nginx.pid', 'nginx')
7
+ ENV['script'] = " #{args[:nginx] || '/usr/sbin/nginx'}" +
8
+ " -c #{args[:config] || 'config/nginx.conf'}"
9
+ ENV['pidfile'] = 'tmp/pids/nginx.pid'
10
+ Rake::Task['app:signal:start'].invoke
19
11
  end
20
12
 
21
13
  desc 'stop nginx'
22
14
  task :stop, [:timeout] do |t, args|
23
15
  # sh "kill -TERM `cat tmp/pids/nginx.pid`"
24
- AppDeploy.term('tmp/pids/nginx.pid', 'nginx', args[:timeout] || 5)
16
+ ENV['pidfile'] = 'tmp/pids/nginx.pid'
17
+ ENV['timeout'] = args[:timeout]
18
+ ENV['name'] = 'nginx'
19
+ Rake::Task['app:signal:stop'].invoke
25
20
  end
26
21
 
27
22
  desc 'restart nginx'
28
- task :restart => [:stop, :start]
23
+ task :restart, [:config, :nginx, :timeout] => [:stop, :start]
24
+
25
+ desc 'reload config'
26
+ task :reload do
27
+ # sh 'kill -HUP `cat tmp/pids/nginx.pid`'
28
+ ENV['signal'] = 'HUP'
29
+ Rake::Task['app:nginx:kill'].invoke
30
+ end
31
+
32
+ desc 'send a signal to nginx'
33
+ task :kill, [:signal] do |t, args|
34
+ ENV['signal'] = args[:signal]
35
+ ENV['pidfile'] = 'tmp/pids/nginx.pid'
36
+ ENV['name'] = 'nginx'
37
+ Rake::Task['app:signal:kill'].invoke
38
+ end
29
39
 
30
40
  end # of nginx
31
41
  end # of app
@@ -2,29 +2,34 @@
2
2
  namespace :app do
3
3
  namespace :signal do
4
4
 
5
- desc 'invoke command if not running already.'
6
- task :start, [:script, :pid] do |t, args|
7
- if File.exist?(args[:pid])
8
- puts "WARN: pid file #{args[:pid]} already exists, ignoring."
5
+ desc 'execute a script if pidfile is not existed'
6
+ task :start, [:script, :pidfile] do |t, args|
7
+ if File.exist?(args[:pidfile])
8
+ puts "WARN: pid file #{args[:pidfile]} already exists, ignoring."
9
9
  else
10
10
  sh args[:script]
11
11
  end
12
12
  end
13
13
 
14
- desc 'send a signal to a process with a pid file'
15
- task :kill, [:signal] do |t, args|
16
- # sh 'kill -HUP `cat tmp/pids/nginx.pid`'
17
- AppDeploy.kill(args[:signal], 'tmp/pids/nginx.pid', 'nginx')
14
+ desc 'terminate a process with a pidfile'
15
+ task :stop, [:pidfile, :timeout, :name] do |t, args|
16
+ # sh "kill -TERM `cat tmp/pids/nginx.pid`"
17
+ AppDeploy.term(args[:pidfile], args[:name], args[:timeout] || 5)
18
18
  end
19
19
 
20
- desc 'stop nginx'
21
- task :stop, [:timeout] do |t, args|
22
- # sh "kill -TERM `cat tmp/pids/nginx.pid`"
23
- AppDeploy.term('tmp/pids/nginx.pid', 'nginx', args[:timeout] || 5)
20
+ desc 'restart a process with a pidfile'
21
+ task :restart, [:script, :pidfile, :timeout, :name] => [:stop, :start]
22
+
23
+ desc 'send HUP to a process with a pidfile'
24
+ task :reload, [:pidfile, :name] do
25
+ # sh 'kill -HUP `cat tmp/pids/nginx.pid`'
26
+ AppDeploy.kill_pidfile('HUP', args[:pidfile], args[:name])
24
27
  end
25
28
 
26
- desc 'restart nginx'
27
- task :restart => [:stop, :start]
29
+ desc 'send a signal to a process with a pidfile'
30
+ task :kill, [:signal, :pidfile, :name] do |t, args|
31
+ AppDeploy.kill_pidfile(args[:signal], args[:pidfile], args[:name])
32
+ end
28
33
 
29
- end # of nginx
34
+ end # of signal
30
35
  end # of app
@@ -0,0 +1,42 @@
1
+
2
+ namespace :app do
3
+ namespace :unicorn do
4
+
5
+ desc 'start unicorn, default config is config/unicorn.rb'
6
+ task :start, [:config, :env, :unicorn] do |t, args|
7
+ ENV['script'] = "#{args[:unicorn] || 'unicorn'} -D" +
8
+ " -c #{args[:config] || 'config/unicorn.rb'}" +
9
+ " -E #{args[:env] || 'production'}"
10
+ ENV['pidfile'] = 'tmp/pids/unicorn.pid'
11
+ Rake::Task['app:signal:start'].invoke
12
+ end
13
+
14
+ desc 'stop unicorn'
15
+ task :stop, [:timeout] do |t, args|
16
+ # sh "kill -TERM `cat tmp/pids/unicorn.pid`"
17
+ ENV['pidfile'] = 'tmp/pids/unicorn.pid'
18
+ ENV['timeout'] = args[:timeout]
19
+ ENV['name'] = 'unicorn'
20
+ Rake::Task['app:signal:stop'].invoke
21
+ end
22
+
23
+ desc 'restart unicorn'
24
+ task :restart, [:config, :env, :unicorn, :timeout] => [:stop, :start]
25
+
26
+ desc 'reload config'
27
+ task :reload do
28
+ # sh 'kill -HUP `cat tmp/pids/unicorn.pid`'
29
+ ENV['signal'] = 'HUP'
30
+ Rake::Task['app:unicorn:kill'].invoke
31
+ end
32
+
33
+ desc 'send a signal to unicorn'
34
+ task :kill, [:signal] do |t, args|
35
+ ENV['signal'] = args[:signal]
36
+ ENV['pidfile'] = 'tmp/pids/unicorn.pid'
37
+ ENV['name'] = 'unicorn'
38
+ Rake::Task['app:signal:kill'].invoke
39
+ end
40
+
41
+ end # of unicorn
42
+ end # of app
@@ -145,45 +145,49 @@ module AppDeploy
145
145
  end
146
146
  end
147
147
 
148
- def term pid_path, name = nil, limit = 5
149
- if pid = AppDeploy.read_pid(pid_path)
150
- puts "Sending TERM to #{name}(#{pid})..."
151
-
152
- else
153
- return
154
-
155
- end
156
-
148
+ def term pid_path, name = nil, limit = 5, wait = 0.1
157
149
  require 'timeout'
158
- begin
159
- timeout(limit){
150
+ pid = AppDeploy.kill_pidfile('TERM', pid_path, name)
151
+ timeout(limit){
152
+ if pid
160
153
  while true
161
154
  Process.kill('TERM', pid)
162
- sleep(0.1)
155
+ sleep(wait)
163
156
  end
164
- }
165
- rescue Errno::ESRCH
166
- if File.exist?(pid_path)
167
- puts "WARN: No such pid: #{pid}, removing #{pid_path}..."
168
- File.delete(pid_path)
169
- else
170
- puts "Killed #{name}(#{pid})"
171
157
  end
158
+ }
159
+ rescue Errno::ESRCH
160
+ puts "Killed #{name}(#{pid})"
172
161
 
173
- rescue Timeout::Error
174
- puts "Timeout(#{limit}) killing #{name}(#{pid})"
162
+ rescue Timeout::Error
163
+ puts "Timeout(#{limit}) killing #{name}(#{pid})"
175
164
 
176
- end
177
165
  end
178
166
 
179
- def hup pid_path, name = nil
167
+ def kill_pidfile signal, pid_path, name = nil
180
168
  if pid = AppDeploy.read_pid(pid_path)
181
- puts "Sending HUP to #{name}(#{pid})..."
182
- Process.kill('HUP', pid)
169
+ AppDeploy.kill_raise(signal, pid, name)
170
+ return pid
183
171
  end
172
+ nil
184
173
  rescue Errno::ESRCH
185
174
  puts "WARN: No such pid: #{pid}, removing #{pid_path}..."
186
175
  File.delete(pid_path)
176
+ nil
177
+ end
178
+
179
+ def kill_pid signal, pid, name = nil
180
+ AppDeploy.kill_raise(signal, pid, name)
181
+ pid
182
+ rescue Errno::ESRCH
183
+ puts "WARN: No such pid: #{pid}"
184
+ nil
185
+ end
186
+
187
+ def kill_raise signal, pid, name = nil
188
+ puts "Sending #{signal} to #{name}(#{pid})..."
189
+ Process.kill(signal, pid)
190
+ pid
187
191
  end
188
192
 
189
193
  end
@@ -1,4 +1,4 @@
1
1
 
2
2
  module AppDeploy
3
- VERSION = '0.6.0'
3
+ VERSION = '0.7.0'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: app-deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Lin Jen-Shin (aka godfat \xE7\x9C\x9F\xE5\xB8\xB8)"
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-14 00:00:00 +08:00
12
+ date: 2009-12-16 00:00:00 +08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -54,6 +54,7 @@ extra_rdoc_files:
54
54
  - lib/app-deploy/server.rake
55
55
  - lib/app-deploy/signal.rake
56
56
  - lib/app-deploy/thin.rake
57
+ - lib/app-deploy/unicorn.rake
57
58
  files:
58
59
  - CHANGES
59
60
  - README
@@ -84,6 +85,7 @@ files:
84
85
  - lib/app-deploy/server.rake
85
86
  - lib/app-deploy/signal.rake
86
87
  - lib/app-deploy/thin.rake
88
+ - lib/app-deploy/unicorn.rake
87
89
  - lib/app-deploy/utils.rb
88
90
  - lib/app-deploy/version.rb
89
91
  has_rdoc: true