app-deploy 0.7.2 → 0.8.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,8 @@
1
1
  = app-deploy changes history
2
2
 
3
+ == app-deploy 0.8.0 / 2010-03-22
4
+ * extracted remote tasks from install tasks
5
+
3
6
  == app-deploy 0.7.2 / 2009-12-21
4
7
  * fixed timeout, call to_i on timeout argument.
5
8
  * fixed signal:reload taking args
data/README CHANGED
@@ -14,47 +14,48 @@ by Lin Jen-Shin (aka godfat-真常[http://godfat.org])
14
14
 
15
15
  $ rake -T app
16
16
  (in /Users/godfat/project/godfat/app-deploy)
17
- rake app:daemon:restart[config] # restart the daemon cluster
18
- rake app:daemon:start[config] # start the daemon cluster
19
- rake app:daemon:stop[config] # stop the daemon cluster
20
- rake app:deploy # deploy to master state
21
- rake app:deploy:after # after deploy hook for you to override
22
- rake app:deploy:before # before deploy hook for you to override
23
- rake app:gem:install # install gems
24
- rake app:gem:reinstall # reinstall gems
25
- rake app:gem:uninstall # uninstall gems
26
- rake app:git[cmd] # generic git cmd walk through all dependency
27
- rake app:git:clone # clone repoitory from github
28
- rake app:git:pull # pull anything from origin
29
- rake app:git:stash # make anything reflect master state
30
- rake app:git:submodule # init and update submodule
31
- rake app:install # install this application
32
- rake app:install:after # after install hook for you to override
33
- rake app:install:before # before install hook for you to override
34
- rake app:install:remote[hosts,git,cd,branch,script] # remote installation
35
- rake app:install:remote:setup[user,file,hosts,script] # upload a tarball and untar to user home, then useradd
36
- rake app:install:remote:sh[hosts,script] # invoke a shell script on remote machines
37
- rake app:install:remote:upload[file,hosts,path] # upload a file to remote machines
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
40
- rake app:nginx:reload # reload config
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
43
- rake app:nginx:stop[timeout] # stop nginx
44
- rake app:rack:restart[config] # restart the rack cluster
45
- rake app:rack:start[config] # start the rack cluster
46
- rake app:rack:stop[config] # stop the rack cluster
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
17
+ rake app:daemon:restart[config] # restart the daemon cluster
18
+ rake app:daemon:start[config] # start the daemon cluster
19
+ rake app:daemon:stop[config] # stop the daemon cluster
20
+ rake app:deploy # deploy to master state
21
+ rake app:deploy:after # after deploy hook for you to override
22
+ rake app:deploy:before # before deploy hook for you to override
23
+ rake app:gem:install # install gems
24
+ rake app:gem:reinstall # reinstall gems
25
+ rake app:gem:uninstall # uninstall gems
26
+ rake app:git[cmd] # generic git cmd walk through all dependency
27
+ rake app:git:clone # clone repoitory from github
28
+ rake app:git:pull # pull anything from origin
29
+ rake app:git:stash # make anything reflect master state
30
+ rake app:git:submodule # init and update submodule
31
+ rake app:install # install this application
32
+ rake app:install:after # after install hook for you to override
33
+ rake app:install:before # before install hook for you to override
34
+ rake app:install:remote[hosts,git,cd,branch,script] # remote installation
35
+ rake app:nginx:kill[signal] # send a signal to nginx
36
+ rake app:nginx:reload # reload config
37
+ rake app:nginx:restart[config,nginx,timeout] # restart nginx
38
+ rake app:nginx:start[config,nginx] # start nginx, default config is config/nginx.conf
39
+ rake app:nginx:stop[timeout] # stop nginx
40
+ rake app:rack:restart[config] # restart the rack cluster
41
+ rake app:rack:start[config] # start the rack cluster
42
+ rake app:rack:stop[config] # stop the rack cluster
43
+ rake app:remote:setup[user,file,hosts,script] # upload a tarball and untar to user home, then useradd
44
+ rake app:remote:sh[hosts,script] # invoke a shell script on remote machines
45
+ rake app:remote:upload[file,hosts,path] # upload a file to remote machines
46
+ rake app:remote:useradd[user,hosts,script] # create a user on remote machines
47
+ rake app:server:reload # reload nginx(passenger)
48
+ rake app:server:restart # please define your server:restart task
49
+ rake app:signal:kill[signal,pidfile,name] # send a signal to a process with a pidfile
50
+ rake app:signal:reload[pidfile,name] # send HUP to a process with a pidfile
51
+ rake app:signal:restart[script,pidfile,name,timeout] # restart a process with a pidfile
52
+ rake app:signal:start[script,pidfile] # execute a script if pidfile is not existed
53
+ rake app:signal:stop[pidfile,name,timeout] # terminate a process with a pidfile
54
+ rake app:unicorn:kill[signal] # send a signal to unicorn
55
+ rake app:unicorn:reload # reload config
56
+ rake app:unicorn:restart[config,env,unicorn,timeout] # restart unicorn
57
+ rake app:unicorn:start[config,env,unicorn] # start unicorn, default config is config/unicorn.rb
58
+ rake app:unicorn:stop[timeout] # stop unicorn
58
59
 
59
60
  == SYNOPSIS:
60
61
 
@@ -0,0 +1,11 @@
1
+
2
+ $ ./bin/start.sh # start or restart server with git HEAD
3
+ $ ./bin/restart.sh # restart server with local modification
4
+
5
+ $ ./bin/update.sh # update to latest version, and call ./bin/start.sh
6
+ $ ./bin/install.sh # install the entire application, and call ./bin/start.sh
7
+
8
+ $ ./bin/remote_install.sh # useradd on each node and execute ./bin/install.sh on them
9
+ $ ./bin/remote_update.sh # call ./bin/update.sh on each node
10
+
11
+ $ ./bin/remote_sh.sh 'command' # execute `command' on each node
@@ -1,4 +1,5 @@
1
1
  #!/bin/sh
2
2
 
3
+ gem install rake
3
4
  rake app:install
4
5
  ./bin/start.sh
@@ -1,9 +1,13 @@
1
1
  #!/bin/sh
2
2
 
3
- rake app:install:remote:setup user=cas file=ssh.tgz hosts=root@10.0.0.101,root@10.0.0.106,root@10.0.0.111,root@10.0.0.116,root@10.0.0.121
3
+ source .bash_profile
4
4
 
5
- rake app:install:remote hosts=cas@10.0.0.101,cas@10.0.0.106,cas@10.0.0.111,cas@10.0.0.116,cas@10.0.0.121 \
6
- git=git@github.com:godfat/cas.git \
7
- cd=~ \
8
- branch=origin/stable \
9
- script=./bin/install.sh
5
+ rake app:remote:useradd user=$project hosts=$nodes
6
+
7
+ rake app:remote:install hosts=$nodes \
8
+ git=git@github.com:godfat/$project.git \
9
+ cd=/home/$project \
10
+ branch=origin/$branch \
11
+ script="git submodule init; git submodule update; gem install rake; ./roodo-rc/install.rb; chown $project:$project -R ."
12
+
13
+ rake app:remote:sh hosts=$hosts script='./bin/install.sh'
@@ -0,0 +1,5 @@
1
+ #!/bin/sh
2
+
3
+ source .bash_profile
4
+
5
+ rake app:remote:sh hosts=$hosts script=./bin/restart.sh
@@ -0,0 +1,5 @@
1
+ #!/bin/sh
2
+
3
+ source .bash_profile
4
+
5
+ rake app:remote:sh hosts=$hosts script="$1"
@@ -1,3 +1,5 @@
1
1
  #!/bin/sh
2
2
 
3
- rake app:install:remote:sh hosts=cas@10.0.0.101,cas@10.0.0.106,cas@10.0.0.111,cas@10.0.0.116,cas@10.0.0.121 script=./bin/update.sh
3
+ source .bash_profile
4
+
5
+ rake app:remote:sh hosts=$hosts script=./bin/update.sh
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+
3
+ # restart server with local modification
4
+ rake app:server:restart
@@ -1,3 +1,5 @@
1
1
  #!/bin/sh
2
2
 
3
+ # start or restart server with git HEAD
4
+ # i.e. it would remove all local modification
3
5
  rake app:deploy
@@ -1,7 +1,6 @@
1
1
  #!/bin/sh
2
2
 
3
3
  git fetch
4
- git stash
5
- git checkout origin/stable
4
+ git reset --hard origin/$branch
6
5
  git submodule update
7
6
  ./bin/start.sh
@@ -1,6 +1,7 @@
1
1
 
2
2
  require 'app-deploy/utils'
3
3
 
4
- %w[ deploy gem git install server rack daemon signal nginx unicorn].each{ |task|
4
+ %w[ deploy gem git install remote server
5
+ rack daemon signal nginx unicorn].each{ |task|
5
6
  load "app-deploy/#{task}.rake"
6
7
  }
@@ -18,67 +18,7 @@ namespace :app do
18
18
  :after]
19
19
 
20
20
  desc 'remote installation'
21
- task :remote, [:hosts, :git, :cd, :branch, :script] => 'remote:default'
21
+ task :remote, [:hosts, :git, :cd, :branch, :script] => 'remote:install'
22
22
 
23
- namespace :remote do
24
- task :default, [:hosts, :git, :cd, :branch, :script] do |t, args|
25
- unless [args[:hosts], args[:git]].all?
26
- puts 'please fill your arguments like:'
27
- puts " > rake app:install:remote[#{args.names.join(',').upcase}]"
28
- exit(1)
29
- end
30
-
31
- cd = args[:cd] || '~'
32
- branch = args[:branch] || 'master'
33
- tmp = "app-deploy-#{Time.now.to_i}"
34
-
35
- chdir = "cd #{cd}"
36
- clone = "git clone #{args[:git]} /tmp/#{tmp}"
37
- setup = "find /tmp/#{tmp} -maxdepth 1 '!' -name #{tmp} -exec mv -f '{}' #{cd} ';'"
38
- rmdir = "rmdir /tmp/#{tmp}"
39
- check = "git checkout #{branch}"
40
-
41
- script = "#{chdir}; #{clone}; #{setup}; #{rmdir}; #{check}; #{args[:script]}"
42
- Rake::Task['app:install:remote:sh'].invoke(args[:hosts], script)
43
- end
44
-
45
- desc 'invoke a shell script on remote machines'
46
- task :sh, [:hosts, :script] do |t, args|
47
- args[:hosts].split(',').map{ |host|
48
- script = args[:script].gsub('"', '\\"')
49
- Thread.new{ sh "ssh #{host} \"#{script}\"" }
50
- }.each(&:join)
51
- end
52
-
53
- desc 'upload a file to remote machines'
54
- task :upload, [:file, :hosts, :path] do |t, args|
55
- args[:hosts].split(',').each{ |host|
56
- sh "scp #{args[:file]} #{host}:#{args[:path]}"
57
- }
58
- end
59
-
60
- desc 'create a user on remote machines'
61
- task :useradd, [:user, :hosts, :script] do |t, args|
62
- useradd = "sudo useradd -m #{args[:user]}"
63
- args[:hosts].split(',').each{ |host|
64
- script = "#{useradd}; #{args[:script]}".gsub('"', '\\"')
65
- sh "ssh #{host} \"#{script}\""
66
- }
67
- end
68
-
69
- desc 'upload a tarball and untar to user home, then useradd'
70
- task :setup, [:user, :file, :hosts, :script] do |t, args|
71
- path = "/tmp/app-deploy-#{Time.now.to_i}"
72
- Rake::Task['app:install:remote:upload'].invoke(
73
- args[:file], args[:hosts], path)
74
-
75
- script = "sudo -u #{args[:user]} tar -zxf #{path}" +
76
- " -C /home/#{args[:user]};" +
77
- " rm #{path}; #{args[:script]}"
78
- Rake::Task['app:install:remote:useradd'].invoke(
79
- args[:user], args[:hosts], script)
80
- end
81
-
82
- end # of remote
83
23
  end # of install
84
24
  end # of app
@@ -1,10 +1,10 @@
1
1
 
2
2
  namespace :app do
3
3
  namespace :remote do
4
- task :default, [:hosts, :git, :cd, :branch, :script] do |t, args|
4
+ task :install, [:hosts, :git, :cd, :branch, :script] do |t, args|
5
5
  unless [args[:hosts], args[:git]].all?
6
6
  puts 'please fill your arguments like:'
7
- puts " > rake app:install:remote[#{args.names.join(',').upcase}]"
7
+ puts " > rake app:remote:install[#{args.names.join(',').upcase}]"
8
8
  exit(1)
9
9
  end
10
10
 
@@ -19,7 +19,7 @@ namespace :app do
19
19
  check = "git checkout #{branch}"
20
20
 
21
21
  script = "#{chdir}; #{clone}; #{setup}; #{rmdir}; #{check}; #{args[:script]}"
22
- Rake::Task['app:install:remote:sh'].invoke(args[:hosts], script)
22
+ Rake::Task['app:remote:sh'].invoke(args[:hosts], script)
23
23
  end
24
24
 
25
25
  desc 'invoke a shell script on remote machines'
@@ -49,13 +49,13 @@ namespace :app do
49
49
  desc 'upload a tarball and untar to user home, then useradd'
50
50
  task :setup, [:user, :file, :hosts, :script] do |t, args|
51
51
  path = "/tmp/app-deploy-#{Time.now.to_i}"
52
- Rake::Task['app:install:remote:upload'].invoke(
52
+ Rake::Task['app:remote:upload'].invoke(
53
53
  args[:file], args[:hosts], path)
54
54
 
55
55
  script = "sudo -u #{args[:user]} tar -zxf #{path}" +
56
56
  " -C /home/#{args[:user]};" +
57
57
  " rm #{path}; #{args[:script]}"
58
- Rake::Task['app:install:remote:useradd'].invoke(
58
+ Rake::Task['app:remote:useradd'].invoke(
59
59
  args[:user], args[:hosts], script)
60
60
  end
61
61
 
@@ -4,9 +4,14 @@ ns = namespace :app do
4
4
 
5
5
  desc 'start unicorn, default config is config/unicorn.rb'
6
6
  task :start, [:config, :env, :unicorn] do |t, args|
7
- script = "#{args[:unicorn] || 'unicorn'} -D" +
8
- " -c #{args[:config] || 'config/unicorn.rb'}" +
9
- " -E #{args[:env] || 'production'}"
7
+ env = if args[:env]
8
+ " -E #{args[:env]}"
9
+ else
10
+ ''
11
+ end
12
+
13
+ script = "#{args[:unicorn] || 'unicorn'} -D" +
14
+ " -c #{args[:config] || 'config/unicorn.rb'}#{env}"
10
15
  Rake::Task['app:signal:start'].invoke(script, 'tmp/pids/unicorn.pid')
11
16
  end
12
17
 
@@ -1,4 +1,4 @@
1
1
 
2
2
  module AppDeploy
3
- VERSION = '0.7.2'
3
+ VERSION = '0.8.0'
4
4
  end
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: app-deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 8
8
+ - 0
9
+ version: 0.8.0
5
10
  platform: ruby
6
11
  authors:
7
12
  - "Lin Jen-Shin (aka godfat \xE7\x9C\x9F\xE5\xB8\xB8)"
@@ -9,19 +14,23 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2009-12-21 00:00:00 +08:00
17
+ date: 2010-03-22 00:00:00 +08:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: bones
17
- type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
23
- version: 3.2.0
24
- version:
27
+ segments:
28
+ - 3
29
+ - 4
30
+ - 1
31
+ version: 3.4.1
32
+ type: :development
33
+ version_requirements: *id001
25
34
  description: " rake tasks for deployment"
26
35
  email: godfat (XD) godfat.org
27
36
  executables: []
@@ -35,9 +44,13 @@ extra_rdoc_files:
35
44
  - TODO
36
45
  - app-deploy.gemspec
37
46
  - example/Rakefile
47
+ - example/bin/README
38
48
  - example/bin/install.sh
39
49
  - example/bin/remote_install.sh
50
+ - example/bin/remote_restart.sh
51
+ - example/bin/remote_sh.sh
40
52
  - example/bin/remote_update.sh
53
+ - example/bin/restart.sh
41
54
  - example/bin/start.sh
42
55
  - example/bin/update.sh
43
56
  - example/daemon_cluster.yaml
@@ -63,9 +76,13 @@ files:
63
76
  - TODO
64
77
  - app-deploy.gemspec
65
78
  - example/Rakefile
79
+ - example/bin/README
66
80
  - example/bin/install.sh
67
81
  - example/bin/remote_install.sh
82
+ - example/bin/remote_restart.sh
83
+ - example/bin/remote_sh.sh
68
84
  - example/bin/remote_update.sh
85
+ - example/bin/restart.sh
69
86
  - example/bin/start.sh
70
87
  - example/bin/update.sh
71
88
  - example/daemon_cluster.yaml
@@ -104,18 +121,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
104
121
  requirements:
105
122
  - - ">="
106
123
  - !ruby/object:Gem::Version
124
+ segments:
125
+ - 0
107
126
  version: "0"
108
- version:
109
127
  required_rubygems_version: !ruby/object:Gem::Requirement
110
128
  requirements:
111
129
  - - ">="
112
130
  - !ruby/object:Gem::Version
131
+ segments:
132
+ - 0
113
133
  version: "0"
114
- version:
115
134
  requirements: []
116
135
 
117
136
  rubyforge_project: app-deploy
118
- rubygems_version: 1.3.5
137
+ rubygems_version: 1.3.6
119
138
  signing_key:
120
139
  specification_version: 3
121
140
  summary: rake tasks for deployment