caploy 0.1.12 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,8 +4,10 @@ Capistrano::Configuration.instance.load do
4
4
  #_cset :bundle_gemfile, "Gemfile"
5
5
  #_cset :bundle_dir, File.join(fetch(:shared_path), 'bundle')
6
6
  #_cset :bundle_roles, #{role_default} # e.g. [:app, :batch]
7
- #_cset :bundle_cmd, "/home/deploy/.rbenv/shims/bundle"
7
+ #_cset :rake, "bundle --gemfile Gemfile.server exec rake"
8
+ _cset :bundle_cmd, "bundle"
8
9
  _cset :bundle_without, [:development, :test, :deploy]
10
+
9
11
  # http://shapeshed.com/journal/using-rbenv-to-manage-rubies/
10
12
  # you can also apply a clever technique to allow you switch versions of ruby by pushing a new .rbenv-version file with capistrano. From version 1.1rc bundler allows you to specify a shebang for binstubs. To use this add the following to your capistrano recipe.
11
13
  _cset :bundle_flags, "--deployment --quiet --binstubs --shebang ruby-local-exec"
@@ -48,7 +48,7 @@ Capistrano::Configuration.instance.load do |instance|
48
48
  task :dynamic_migrations do
49
49
  from = source.next_revision(current_revision)
50
50
  if capture("cd #{latest_release} && #{source.local.log(from)} db/migrate | wc -l").to_i > 0
51
- run "cd #{current_release} && RAILS_ENV=#{rails_env} bundle exec rake db:migrate"
51
+ run "cd #{current_release} && RAILS_ENV=#{rails_env} #{rake} db:migrate"
52
52
  logger.info "New migrations added - running migrations."
53
53
  else
54
54
  logger.info "Skipping migrations - there are not any new."
@@ -48,7 +48,7 @@ Capistrano::Configuration.instance.load do
48
48
 
49
49
  desc "build missing paperclip styles"
50
50
  task :build_missing_paperclip_styles, :roles => :app do
51
- run "cd #{current_path}; RAILS_ENV=#{rails_env} bundle exec rake paperclip:refresh:missing_styles"
51
+ run "cd #{current_path}; RAILS_ENV=#{rails_env} #{rake} paperclip:refresh:missing_styles"
52
52
  end
53
53
 
54
54
  desc 'Show deployed revision'
@@ -3,7 +3,7 @@ Capistrano::Configuration.instance.load do
3
3
  namespace :deploy do
4
4
  desc "build missing paperclip styles"
5
5
  task :build_missing_paperclip_styles, :roles => :app do
6
- run "cd #{release_path}; RAILS_ENV=#{rails_env} bundle exec rake paperclip:refresh:missing_styles"
6
+ run "cd #{release_path}; RAILS_ENV=#{rails_env} #{rake} paperclip:refresh:missing_styles"
7
7
  end
8
8
  end
9
9
 
@@ -2,7 +2,7 @@ Capistrano::Configuration.instance.load do
2
2
 
3
3
  namespace :deploy do
4
4
  task :seed, :roles => :app do
5
- run "cd #{current_path} && RAILS_ENV=#{rails_env} bundle exec rake db:seed"
5
+ run "cd #{current_path} && RAILS_ENV=#{rails_env} #{rake} db:seed"
6
6
  end
7
7
  end
8
8
 
@@ -1,150 +1,136 @@
1
- require 'capistrano'
2
- require 'capistrano/version'
1
+ Capistrano::Configuration.instance.load do
3
2
 
4
- module Unicorn
5
- class CapistranoIntegration
6
- def self.load_into(capistrano_config)
7
- capistrano_config.load do
8
-
9
- # Check if remote file exists
10
- #
11
- def remote_file_exists?(full_path)
12
- 'true' == capture("if [ -e #{full_path} ]; then echo 'true'; fi").strip
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
20
-
21
- # Set unicorn vars
22
- #
23
- _cset(:app_env, (fetch(:rails_env) rescue 'production'))
24
- _cset :unicorn_bin, "bundle exec unicorn"
25
- _cset(:unicorn_pid, "#{fetch(:current_path)}/tmp/pids/unicorn.pid")
26
- _cset(:unicorn_env, (fetch(:app_env)))
27
- _cset :unicorn_std_log, "log/unicorn.stderr.log"
28
- _cset :unicorn_err_log, "log/unicorn.stderr.log"
29
- _cset :unicorn_worker_processes, 2
30
- _cset :unicorn_timeout, 30
31
- _cset :unicorn_listen_backlog, 2048
32
- _cset :sidekiq_redis_count, 1
33
- _cset :sidekiq_redis_url, nil
34
- _cset :unicorn_hard_restart, false
35
-
36
- namespace :unicorn do
37
- desc 'Start Unicorn'
38
- task :start, :roles => :app, :except => {:no_release => true} do
39
- if remote_file_exists?(unicorn_pid)
40
- if process_exists?(unicorn_pid)
41
- logger.important("Unicorn is already running!", "Unicorn")
42
- next
43
- else
44
- run "rm #{unicorn_pid}"
45
- end
46
- end
3
+ # Check if remote file exists
4
+ #
5
+ def remote_file_exists?(full_path)
6
+ 'true' == capture("if [ -e #{full_path} ]; then echo 'true'; fi").strip
7
+ end
47
8
 
48
- config_path = "#{current_path}/config/unicorn/#{unicorn_env}.rb"
49
- if remote_file_exists?(config_path)
50
- logger.important("Starting...", "Unicorn")
51
- run "cd #{current_path} && BUNDLE_GEMFILE=#{current_path}/Gemfile bundle exec #{unicorn_bin} -c #{config_path} -E #{app_env} -D"
52
- else
53
- logger.important("Config file for \"#{unicorn_env}\" environment was not found at \"#{config_path}\"", "Unicorn")
54
- end
55
- end
9
+ # Check if process is running
10
+ #
11
+ def process_exists?(pid_file)
12
+ capture("ps -p $(cat #{pid_file}) ; true").strip.split("\n").size == 2
13
+ end
56
14
 
57
- desc 'Stop Unicorn'
58
- task :stop, :roles => :app, :except => {:no_release => true} do
59
- if remote_file_exists?(unicorn_pid)
60
- if process_exists?(unicorn_pid)
61
- logger.important("Stopping...", "Unicorn")
62
- run "#{try_sudo} kill `cat #{unicorn_pid}`"
63
- else
64
- run "rm #{unicorn_pid}"
65
- logger.important("Unicorn is not running.", "Unicorn")
66
- end
67
- else
68
- logger.important("No PIDs found. Check if unicorn is running.", "Unicorn")
69
- end
70
- end
15
+ # Set unicorn vars
16
+ #
17
+ _cset :app_env, fetch(:rails_env, 'production')
18
+ _cset :unicorn_bin, "unicorn"
19
+ _cset :unicorn_pid, "#{fetch(:current_path)}/tmp/pids/unicorn.pid"
20
+ _cset :unicorn_env, app_env
21
+ _cset :unicorn_std_log, "log/unicorn.stderr.log"
22
+ _cset :unicorn_err_log, "log/unicorn.stderr.log"
23
+ _cset :unicorn_worker_processes, 2
24
+ _cset :unicorn_timeout, 30
25
+ _cset :unicorn_listen_backlog, 2048
26
+ _cset :sidekiq_redis_url, nil
27
+ _cset :unicorn_hard_restart, false
71
28
 
72
- desc 'Unicorn graceful shutdown'
73
- task :graceful_stop, :roles => :app, :except => {:no_release => true} do
74
- if remote_file_exists?(unicorn_pid)
75
- if process_exists?(unicorn_pid)
76
- logger.important("Stopping...", "Unicorn")
77
- run "#{try_sudo} kill -s QUIT `cat #{unicorn_pid}`"
78
- else
79
- run "rm #{unicorn_pid}"
80
- logger.important("Unicorn is not running.", "Unicorn")
81
- end
82
- else
83
- logger.important("No PIDs found. Check if unicorn is running.", "Unicorn")
84
- end
85
- end
29
+ namespace :unicorn do
30
+ desc 'Start Unicorn'
31
+ task :start, :roles => :app, :except => {:no_release => true} do
32
+ if remote_file_exists?(unicorn_pid)
33
+ if process_exists?(unicorn_pid)
34
+ logger.important("Unicorn is already running!", "Unicorn")
35
+ next
36
+ else
37
+ run "rm #{unicorn_pid}"
38
+ end
39
+ end
86
40
 
87
- desc 'Reload Unicorn'
88
- task :reload, :roles => :app, :except => {:no_release => true} do
89
- if remote_file_exists?(unicorn_pid)
90
- logger.important("Stopping...", "Unicorn")
91
- if unicorn_hard_restart
92
- unicorn.stop
93
- sleep(2)
94
- unicorn.start
95
- else
96
- run "#{try_sudo} kill -s USR2 `cat #{unicorn_pid}`"
97
- end
98
- else
99
- logger.important("No PIDs found. Starting Unicorn server...", "Unicorn")
100
- config_path = "#{current_path}/config/unicorn/#{unicorn_env}.rb"
101
- if remote_file_exists?(config_path)
102
- run "cd #{current_path} && BUNDLE_GEMFILE=#{current_path}/Gemfile bundle exec #{unicorn_bin} -c #{config_path} -E #{app_env} -D"
103
- else
104
- logger.important("Config file for \"#{unicorn_env}\" environment was not found at \"#{config_path}\"", "Unicorn")
105
- end
106
- end
107
- end
41
+ config_path = "#{current_path}/config/unicorn/#{unicorn_env}.rb"
42
+ if remote_file_exists?(config_path)
43
+ logger.important("Starting...", "Unicorn - #{bundle_cmd} ")
44
+ run "cd #{current_path} && #{bundle_cmd} exec #{unicorn_bin} -c #{config_path} -E #{app_env} -D"
45
+ else
46
+ logger.important("Config file for \"#{unicorn_env}\" environment was not found at \"#{config_path}\"", "Unicorn")
47
+ end
48
+ end
108
49
 
109
- desc "Setup unicorn"
110
- task :setup, :roles => :app, :except => {:no_release => true} do
111
- run "mkdir -p \"#{shared_path}/config/unicorn\""
112
- config_path = "#{shared_path}/config/unicorn/#{rails_env}.rb"
113
- template_path = File.expand_path('../../templates/unicorn/unicorn.rb.erb', __FILE__)
114
- vars = {
115
- 'application' => application,
116
- 'current_path' => current_path,
117
- 'unicorn_pid' => unicorn_pid,
118
- 'unicorn_std_log' => unicorn_std_log,
119
- 'unicorn_err_log' => unicorn_err_log,
120
- 'stage' => stage,
121
- 'unicorn_listen_backlog' => unicorn_listen_backlog,
122
- 'unicorn_worker_processes' => unicorn_worker_processes,
123
- 'unicorn_timeout' => unicorn_timeout,
124
- 'sidekiq_redis_count' => sidekiq_redis_count,
125
- 'sidekiq_redis_url' => sidekiq_redis_url
126
- }
127
- put(render_erb_template(template_path, vars), config_path)
128
- end
50
+ desc 'Stop Unicorn'
51
+ task :stop, :roles => :app, :except => {:no_release => true} do
52
+ if remote_file_exists?(unicorn_pid)
53
+ if process_exists?(unicorn_pid)
54
+ logger.important("Stopping...", "Unicorn")
55
+ run "#{try_sudo} kill `cat #{unicorn_pid}`"
56
+ else
57
+ run "rm #{unicorn_pid}"
58
+ logger.important("Unicorn is not running.", "Unicorn")
129
59
  end
60
+ else
61
+ logger.important("No PIDs found. Check if unicorn is running.", "Unicorn")
62
+ end
63
+ end
130
64
 
131
- after :"deploy:restart", :"unicorn:reload"
132
- after :"deploy:setup", :"unicorn:setup";
133
-
134
- namespace :deploy do
135
- task :start, :roles => :app do
136
- unicorn.start
137
- end
65
+ desc 'Unicorn graceful shutdown'
66
+ task :graceful_stop, :roles => :app, :except => {:no_release => true} do
67
+ if remote_file_exists?(unicorn_pid)
68
+ if process_exists?(unicorn_pid)
69
+ logger.important("Stopping...", "Unicorn")
70
+ run "#{try_sudo} kill -s QUIT `cat #{unicorn_pid}`"
71
+ else
72
+ run "rm #{unicorn_pid}"
73
+ logger.important("Unicorn is not running.", "Unicorn")
74
+ end
75
+ else
76
+ logger.important("No PIDs found. Check if unicorn is running.", "Unicorn")
77
+ end
78
+ end
138
79
 
139
- task :stop, :roles => :app do
140
- unicorn.stop
141
- end
80
+ desc 'Reload Unicorn'
81
+ task :reload, :roles => :app, :except => {:no_release => true} do
82
+ if remote_file_exists?(unicorn_pid)
83
+ logger.important("Stopping...", "Unicorn")
84
+ if unicorn_hard_restart
85
+ unicorn.stop
86
+ sleep(2)
87
+ unicorn.start
88
+ else
89
+ run "#{try_sudo} kill -s USR2 `cat #{unicorn_pid}`"
90
+ end
91
+ else
92
+ logger.important("No PIDs found. Starting Unicorn server...", "Unicorn")
93
+ config_path = "#{current_path}/config/unicorn/#{unicorn_env}.rb"
94
+ if remote_file_exists?(config_path)
95
+ run "cd #{current_path} && #{bundle_cmd} exec #{unicorn_bin} -c #{config_path} -E #{app_env} -D"
96
+ else
97
+ logger.important("Config file for \"#{unicorn_env}\" environment was not found at \"#{config_path}\"", "Unicorn")
142
98
  end
143
99
  end
144
100
  end
101
+
102
+ desc "Setup unicorn"
103
+ task :setup, :roles => :app, :except => {:no_release => true} do
104
+ run "mkdir -p \"#{shared_path}/config/unicorn\""
105
+ config_path = "#{shared_path}/config/unicorn/#{rails_env}.rb"
106
+ template_path = File.expand_path('../../templates/unicorn/unicorn.rb.erb', __FILE__)
107
+ vars = {
108
+ 'application' => application,
109
+ 'current_path' => current_path,
110
+ 'unicorn_pid' => unicorn_pid,
111
+ 'unicorn_std_log' => unicorn_std_log,
112
+ 'unicorn_err_log' => unicorn_err_log,
113
+ 'stage' => stage,
114
+ 'unicorn_listen_backlog' => unicorn_listen_backlog,
115
+ 'unicorn_worker_processes' => unicorn_worker_processes,
116
+ 'unicorn_timeout' => unicorn_timeout,
117
+ 'sidekiq_redis_count' => sidekiq_redis_count,
118
+ 'sidekiq_redis_url' => sidekiq_redis_url
119
+ }
120
+ put(render_erb_template(template_path, vars), config_path)
121
+ end
145
122
  end
146
- end
147
123
 
148
- if Capistrano::Configuration.instance
149
- Unicorn::CapistranoIntegration.load_into(Capistrano::Configuration.instance)
124
+ after :"deploy:restart", :"unicorn:reload"
125
+ after :"deploy:setup", :"unicorn:setup";
126
+
127
+ namespace :deploy do
128
+ task :start, :roles => :app do
129
+ unicorn.start
130
+ end
131
+
132
+ task :stop, :roles => :app do
133
+ unicorn.stop
134
+ end
135
+ end
150
136
  end
@@ -1,3 +1,3 @@
1
1
  module Caploy
2
- VERSION = "0.1.12"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/mysql.rb CHANGED
@@ -50,7 +50,7 @@ module Database
50
50
  # cleanup = true removes the mysqldump file after loading, false leaves it in db/
51
51
  def load(file, cleanup)
52
52
  unzip_file = File.join(File.dirname(file), File.basename(file, '.bz2'))
53
- @cap.run "cd #{@cap.current_path}; bunzip2 -f #{file} && RAILS_ENV=#{@cap.rails_env} rake db:drop db:create && #{import_cmd(unzip_file)}"
53
+ @cap.run "cd #{@cap.current_path}; bunzip2 -f #{file} && RAILS_ENV=#{@cap.rails_env} #{rake} db:drop db:create && #{import_cmd(unzip_file)}"
54
54
  File.unlink(unzip_file) if cleanup
55
55
  end
56
56
  end
@@ -64,7 +64,7 @@ module Database
64
64
  # cleanup = true removes the mysqldump file after loading, false leaves it in db/
65
65
  def load(file, cleanup)
66
66
  unzip_file = File.join(File.dirname(file), File.basename(file, '.bz2'))
67
- system("bunzip2 -f #{file} && rake db:drop db:create && #{import_cmd(unzip_file)} && rake db:migrate")
67
+ system("bunzip2 -f #{file} && #{rake} db:drop db:create && #{import_cmd(unzip_file)} && #{rake} db:migrate")
68
68
  File.unlink(unzip_file) if cleanup
69
69
  end
70
70
 
metadata CHANGED
@@ -2,143 +2,143 @@
2
2
  name: caploy
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.12
5
+ version: 0.2.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Michael Schiller
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-20 00:00:00.000000000 Z
12
+ date: 2013-05-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- version_requirements: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ! '>='
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- none: false
21
15
  name: gemcutter
22
16
  type: :runtime
23
- prerelease: false
24
17
  requirement: !ruby/object:Gem::Requirement
18
+ none: false
25
19
  requirements:
26
20
  - - ! '>='
27
21
  - !ruby/object:Gem::Version
28
22
  version: '0'
29
- none: false
30
- - !ruby/object:Gem::Dependency
23
+ prerelease: false
31
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
32
26
  requirements:
33
27
  - - ! '>='
34
28
  - !ruby/object:Gem::Version
35
- version: 2.13.4
36
- none: false
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
37
31
  name: capistrano
38
32
  type: :runtime
39
- prerelease: false
40
33
  requirement: !ruby/object:Gem::Requirement
34
+ none: false
41
35
  requirements:
42
36
  - - ! '>='
43
37
  - !ruby/object:Gem::Version
44
38
  version: 2.13.4
45
- none: false
46
- - !ruby/object:Gem::Dependency
39
+ prerelease: false
47
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
48
42
  requirements:
49
43
  - - ! '>='
50
44
  - !ruby/object:Gem::Version
51
- version: 1.2.1
52
- none: false
45
+ version: 2.13.4
46
+ - !ruby/object:Gem::Dependency
53
47
  name: capistrano-ext
54
48
  type: :runtime
55
- prerelease: false
56
49
  requirement: !ruby/object:Gem::Requirement
50
+ none: false
57
51
  requirements:
58
52
  - - ! '>='
59
53
  - !ruby/object:Gem::Version
60
54
  version: 1.2.1
61
- none: false
62
- - !ruby/object:Gem::Dependency
55
+ prerelease: false
63
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
64
58
  requirements:
65
59
  - - ! '>='
66
60
  - !ruby/object:Gem::Version
67
- version: 0.5.5
68
- none: false
61
+ version: 1.2.1
62
+ - !ruby/object:Gem::Dependency
69
63
  name: capistrano_colors
70
64
  type: :runtime
71
- prerelease: false
72
65
  requirement: !ruby/object:Gem::Requirement
66
+ none: false
73
67
  requirements:
74
68
  - - ! '>='
75
69
  - !ruby/object:Gem::Version
76
70
  version: 0.5.5
77
- none: false
78
- - !ruby/object:Gem::Dependency
71
+ prerelease: false
79
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
80
74
  requirements:
81
75
  - - ! '>='
82
76
  - !ruby/object:Gem::Version
83
- version: 0.1.0
84
- none: false
77
+ version: 0.5.5
78
+ - !ruby/object:Gem::Dependency
85
79
  name: capistrano-file_db
86
80
  type: :runtime
87
- prerelease: false
88
81
  requirement: !ruby/object:Gem::Requirement
82
+ none: false
89
83
  requirements:
90
84
  - - ! '>='
91
85
  - !ruby/object:Gem::Version
92
86
  version: 0.1.0
93
- none: false
94
- - !ruby/object:Gem::Dependency
87
+ prerelease: false
95
88
  version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
96
90
  requirements:
97
91
  - - ! '>='
98
92
  - !ruby/object:Gem::Version
99
- version: 0.0.2
100
- none: false
93
+ version: 0.1.0
94
+ - !ruby/object:Gem::Dependency
101
95
  name: capistrano-uptodate
102
96
  type: :runtime
103
- prerelease: false
104
97
  requirement: !ruby/object:Gem::Requirement
98
+ none: false
105
99
  requirements:
106
100
  - - ! '>='
107
101
  - !ruby/object:Gem::Version
108
102
  version: 0.0.2
109
- none: false
110
- - !ruby/object:Gem::Dependency
103
+ prerelease: false
111
104
  version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
112
106
  requirements:
113
107
  - - ! '>='
114
108
  - !ruby/object:Gem::Version
115
- version: 1.2.2
116
- none: false
109
+ version: 0.0.2
110
+ - !ruby/object:Gem::Dependency
117
111
  name: rvm-capistrano
118
112
  type: :runtime
119
- prerelease: false
120
113
  requirement: !ruby/object:Gem::Requirement
114
+ none: false
121
115
  requirements:
122
116
  - - ! '>='
123
117
  - !ruby/object:Gem::Version
124
118
  version: 1.2.2
125
- none: false
126
- - !ruby/object:Gem::Dependency
119
+ prerelease: false
127
120
  version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
128
122
  requirements:
129
123
  - - ! '>='
130
124
  - !ruby/object:Gem::Version
131
- version: '0'
132
- none: false
125
+ version: 1.2.2
126
+ - !ruby/object:Gem::Dependency
133
127
  name: erubis
134
128
  type: :runtime
135
- prerelease: false
136
129
  requirement: !ruby/object:Gem::Requirement
130
+ none: false
137
131
  requirements:
138
132
  - - ! '>='
139
133
  - !ruby/object:Gem::Version
140
134
  version: '0'
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
141
137
  none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
142
  description: capistrano deployment task for my projects
143
143
  email:
144
144
  - michael.schiller@gmx.de
@@ -189,17 +189,17 @@ rdoc_options: []
189
189
  require_paths:
190
190
  - lib
191
191
  required_ruby_version: !ruby/object:Gem::Requirement
192
+ none: false
192
193
  requirements:
193
194
  - - ! '>='
194
195
  - !ruby/object:Gem::Version
195
196
  version: '0'
196
- none: false
197
197
  required_rubygems_version: !ruby/object:Gem::Requirement
198
+ none: false
198
199
  requirements:
199
200
  - - ! '>='
200
201
  - !ruby/object:Gem::Version
201
202
  version: '0'
202
- none: false
203
203
  requirements: []
204
204
  rubyforge_project:
205
205
  rubygems_version: 1.8.23
@@ -207,3 +207,4 @@ signing_key:
207
207
  specification_version: 3
208
208
  summary: capistrano deployment task for my projects
209
209
  test_files: []
210
+ has_rdoc: