caploy 0.1.4 → 0.1.5

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/caploy.gemspec CHANGED
@@ -16,10 +16,9 @@ Gem::Specification.new do |gem|
16
16
 
17
17
  gem.add_dependency('gemcutter')
18
18
 
19
- gem.add_dependency('capistrano', '>= 2.12.0')
19
+ gem.add_dependency('capistrano', '>= 2.13.4')
20
20
  gem.add_dependency('capistrano-ext', '>= 1.2.1')
21
21
  gem.add_dependency('capistrano_colors', '>= 0.5.5')
22
- gem.add_dependency('capistrano-unicorn', '>= 0.1.6')
23
22
  gem.add_dependency('capistrano-file_db', '>= 0.1.0')
24
23
  gem.add_dependency('capistrano-uptodate', '>= 0.0.2')
25
24
  gem.add_dependency('rvm-capistrano', '>= 1.2.2')
@@ -1,45 +1,147 @@
1
- Capistrano::Configuration.instance.load do
2
-
3
- _cset :unicorn_bin, "bundle exec unicorn"
4
- _cset :unicorn_pid, "#{deploy_to}/current/tmp/pids/unicorn.pid"
5
- _cset :unicorn_std_log, "log/unicorn.stderr.log"
6
- _cset :unicorn_err_log, "log/unicorn.stderr.log"
7
- _cset :unicorn_worker_processes, 2
8
- _cset :unicorn_listen_backlog, 2048
9
- _cset :sidekiq_redis_count, 1
10
-
11
- require "capistrano-unicorn"
12
-
13
- namespace :unicorn do
14
- desc "Setup unicorn"
15
- task :setup, :roles => :app, :except => { :no_release => true } do
16
- run "mkdir -p \"#{shared_path}/config/unicorn\""
17
- config_path = "#{shared_path}/config/unicorn/#{rails_env}.rb"
18
- template_path = File.expand_path('../../templates/unicorn/unicorn.rb.erb', __FILE__)
19
- vars = {
20
- 'application'=> application,
21
- 'current_path' => current_path,
22
- 'unicorn_pid' => unicorn_pid,
23
- 'unicorn_std_log' => unicorn_std_log,
24
- 'unicorn_err_log' => unicorn_err_log,
25
- 'stage' => stage,
26
- 'unicorn_listen_backlog' => unicorn_listen_backlog,
27
- 'unicorn_worker_processes' => unicorn_worker_processes,
28
- 'sidekiq_redis_count' => sidekiq_redis_count
29
- }
30
- put(render_erb_template(template_path, vars), config_path)
31
- end
32
- end
1
+ require 'capistrano'
2
+ require 'capistrano/version'
33
3
 
34
- after :"deploy:setup", :"unicorn:setup";
4
+ module Unicorn
5
+ class CapistranoIntegration
6
+ def self.load_into(capistrano_config)
7
+ capistrano_config.load do
35
8
 
36
- namespace :deploy do
37
- task :start, :roles => :app do
38
- unicorn.start
39
- end
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_listen_backlog, 2048
31
+ _cset :sidekiq_redis_count, 1
32
+ _cset :unicorn_hard_restart, false
33
+
34
+ namespace :unicorn do
35
+ desc 'Start Unicorn'
36
+ task :start, :roles => :app, :except => {:no_release => true} do
37
+ if remote_file_exists?(unicorn_pid)
38
+ if process_exists?(unicorn_pid)
39
+ logger.important("Unicorn is already running!", "Unicorn")
40
+ next
41
+ else
42
+ run "rm #{unicorn_pid}"
43
+ end
44
+ end
45
+
46
+ config_path = "#{current_path}/config/unicorn/#{unicorn_env}.rb"
47
+ if remote_file_exists?(config_path)
48
+ logger.important("Starting...", "Unicorn")
49
+ run "cd #{current_path} && BUNDLE_GEMFILE=#{current_path}/Gemfile bundle exec #{unicorn_bin} -c #{config_path} -E #{app_env} -D"
50
+ else
51
+ logger.important("Config file for \"#{unicorn_env}\" environment was not found at \"#{config_path}\"", "Unicorn")
52
+ end
53
+ end
54
+
55
+ desc 'Stop Unicorn'
56
+ task :stop, :roles => :app, :except => {:no_release => true} do
57
+ if remote_file_exists?(unicorn_pid)
58
+ if process_exists?(unicorn_pid)
59
+ logger.important("Stopping...", "Unicorn")
60
+ run "#{try_sudo} kill `cat #{unicorn_pid}`"
61
+ else
62
+ run "rm #{unicorn_pid}"
63
+ logger.important("Unicorn is not running.", "Unicorn")
64
+ end
65
+ else
66
+ logger.important("No PIDs found. Check if unicorn is running.", "Unicorn")
67
+ end
68
+ end
40
69
 
41
- task :stop, :roles => :app do
42
- unicorn.stop
70
+ desc 'Unicorn graceful shutdown'
71
+ task :graceful_stop, :roles => :app, :except => {:no_release => true} do
72
+ if remote_file_exists?(unicorn_pid)
73
+ if process_exists?(unicorn_pid)
74
+ logger.important("Stopping...", "Unicorn")
75
+ run "#{try_sudo} kill -s QUIT `cat #{unicorn_pid}`"
76
+ else
77
+ run "rm #{unicorn_pid}"
78
+ logger.important("Unicorn is not running.", "Unicorn")
79
+ end
80
+ else
81
+ logger.important("No PIDs found. Check if unicorn is running.", "Unicorn")
82
+ end
83
+ end
84
+
85
+ desc 'Reload Unicorn'
86
+ task :reload, :roles => :app, :except => {:no_release => true} do
87
+ if remote_file_exists?(unicorn_pid)
88
+ logger.important("Stopping...", "Unicorn")
89
+ if unicorn_hard_restart
90
+ unicorn.stop
91
+ sleep(2)
92
+ unicorn.start
93
+ else
94
+ run "#{try_sudo} kill -s USR2 `cat #{unicorn_pid}`"
95
+ end
96
+ else
97
+ logger.important("No PIDs found. Starting Unicorn server...", "Unicorn")
98
+ config_path = "#{current_path}/config/unicorn/#{unicorn_env}.rb"
99
+ if remote_file_exists?(config_path)
100
+ run "cd #{current_path} && BUNDLE_GEMFILE=#{current_path}/Gemfile bundle exec #{unicorn_bin} -c #{config_path} -E #{app_env} -D"
101
+ else
102
+ logger.important("Config file for \"#{unicorn_env}\" environment was not found at \"#{config_path}\"", "Unicorn")
103
+ end
104
+ end
105
+ end
106
+ end
107
+
108
+ after "deploy:restart", "unicorn:reload"
109
+
110
+ desc "Setup unicorn"
111
+ task :setup, :roles => :app, :except => {:no_release => true} do
112
+ run "mkdir -p \"#{shared_path}/config/unicorn\""
113
+ config_path = "#{shared_path}/config/unicorn/#{rails_env}.rb"
114
+ template_path = File.expand_path('../../templates/unicorn/unicorn.rb.erb', __FILE__)
115
+ vars = {
116
+ 'application' => application,
117
+ 'current_path' => current_path,
118
+ 'unicorn_pid' => unicorn_pid,
119
+ 'unicorn_std_log' => unicorn_std_log,
120
+ 'unicorn_err_log' => unicorn_err_log,
121
+ 'stage' => stage,
122
+ 'unicorn_listen_backlog' => unicorn_listen_backlog,
123
+ 'unicorn_worker_processes' => unicorn_worker_processes,
124
+ 'sidekiq_redis_count' => sidekiq_redis_count
125
+ }
126
+ put(render_erb_template(template_path, vars), config_path)
127
+ end
128
+
129
+ after :"deploy:setup", :"unicorn:setup";
130
+
131
+ namespace :deploy do
132
+ task :start, :roles => :app do
133
+ unicorn.start
134
+ end
135
+
136
+ task :stop, :roles => :app do
137
+ unicorn.stop
138
+ end
139
+ end
140
+ end
43
141
  end
44
142
  end
45
143
  end
144
+
145
+ if Capistrano::Configuration.instance
146
+ Unicorn::CapistranoIntegration.load_into(Capistrano::Configuration.instance)
147
+ end
@@ -1,3 +1,3 @@
1
1
  module Caploy
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,154 +1,151 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: caploy
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 1
8
- - 4
9
- version: 0.1.4
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.5
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Michael Schiller
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2012-12-19 00:00:00 +01:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2013-01-07 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: gemcutter
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- segments:
28
- - 0
29
- version: "0"
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
30
22
  type: :runtime
31
- version_requirements: *id001
32
- - !ruby/object:Gem::Dependency
33
- name: capistrano
34
23
  prerelease: false
35
- requirement: &id002 !ruby/object:Gem::Requirement
36
- requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- segments:
40
- - 2
41
- - 12
42
- - 0
43
- version: 2.12.0
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: capistrano
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: 2.13.4
44
38
  type: :runtime
45
- version_requirements: *id002
46
- - !ruby/object:Gem::Dependency
47
- name: capistrano-ext
48
39
  prerelease: false
49
- requirement: &id003 !ruby/object:Gem::Requirement
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- segments:
54
- - 1
55
- - 2
56
- - 1
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 2.13.4
46
+ - !ruby/object:Gem::Dependency
47
+ name: capistrano-ext
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
57
53
  version: 1.2.1
58
54
  type: :runtime
59
- version_requirements: *id003
60
- - !ruby/object:Gem::Dependency
61
- name: capistrano_colors
62
55
  prerelease: false
63
- requirement: &id004 !ruby/object:Gem::Requirement
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- segments:
68
- - 0
69
- - 5
70
- - 5
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.2.1
62
+ - !ruby/object:Gem::Dependency
63
+ name: capistrano_colors
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
71
69
  version: 0.5.5
72
70
  type: :runtime
73
- version_requirements: *id004
74
- - !ruby/object:Gem::Dependency
75
- name: capistrano-unicorn
76
71
  prerelease: false
77
- requirement: &id005 !ruby/object:Gem::Requirement
78
- requirements:
79
- - - ">="
80
- - !ruby/object:Gem::Version
81
- segments:
82
- - 0
83
- - 1
84
- - 6
85
- version: 0.1.6
86
- type: :runtime
87
- version_requirements: *id005
88
- - !ruby/object:Gem::Dependency
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: 0.5.5
78
+ - !ruby/object:Gem::Dependency
89
79
  name: capistrano-file_db
90
- prerelease: false
91
- requirement: &id006 !ruby/object:Gem::Requirement
92
- requirements:
93
- - - ">="
94
- - !ruby/object:Gem::Version
95
- segments:
96
- - 0
97
- - 1
98
- - 0
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
99
85
  version: 0.1.0
100
86
  type: :runtime
101
- version_requirements: *id006
102
- - !ruby/object:Gem::Dependency
103
- name: capistrano-uptodate
104
87
  prerelease: false
105
- requirement: &id007 !ruby/object:Gem::Requirement
106
- requirements:
107
- - - ">="
108
- - !ruby/object:Gem::Version
109
- segments:
110
- - 0
111
- - 0
112
- - 2
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: 0.1.0
94
+ - !ruby/object:Gem::Dependency
95
+ name: capistrano-uptodate
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
113
101
  version: 0.0.2
114
102
  type: :runtime
115
- version_requirements: *id007
116
- - !ruby/object:Gem::Dependency
117
- name: rvm-capistrano
118
103
  prerelease: false
119
- requirement: &id008 !ruby/object:Gem::Requirement
120
- requirements:
121
- - - ">="
122
- - !ruby/object:Gem::Version
123
- segments:
124
- - 1
125
- - 2
126
- - 2
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: 0.0.2
110
+ - !ruby/object:Gem::Dependency
111
+ name: rvm-capistrano
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
127
117
  version: 1.2.2
128
118
  type: :runtime
129
- version_requirements: *id008
130
- - !ruby/object:Gem::Dependency
131
- name: erubis
132
119
  prerelease: false
133
- requirement: &id009 !ruby/object:Gem::Requirement
134
- requirements:
135
- - - ">="
136
- - !ruby/object:Gem::Version
137
- segments:
138
- - 0
139
- version: "0"
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: 1.2.2
126
+ - !ruby/object:Gem::Dependency
127
+ name: erubis
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
140
134
  type: :runtime
141
- version_requirements: *id009
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
142
  description: capistrano deployment task for my projects
143
- email:
143
+ email:
144
144
  - michael.schiller@gmx.de
145
145
  executables: []
146
-
147
146
  extensions: []
148
-
149
147
  extra_rdoc_files: []
150
-
151
- files:
148
+ files:
152
149
  - .gitignore
153
150
  - Gemfile
154
151
  - README.md
@@ -185,35 +182,29 @@ files:
185
182
  - lib/examples/deploy.rb
186
183
  - lib/mysql.rb
187
184
  - lib/util.rb
188
- has_rdoc: true
189
185
  homepage: https://github.com/mschiller/caploy
190
186
  licenses: []
191
-
192
187
  post_install_message:
193
188
  rdoc_options: []
194
-
195
- require_paths:
189
+ require_paths:
196
190
  - lib
197
- required_ruby_version: !ruby/object:Gem::Requirement
198
- requirements:
199
- - - ">="
200
- - !ruby/object:Gem::Version
201
- segments:
202
- - 0
203
- version: "0"
204
- required_rubygems_version: !ruby/object:Gem::Requirement
205
- requirements:
206
- - - ">="
207
- - !ruby/object:Gem::Version
208
- segments:
209
- - 0
210
- version: "0"
191
+ required_ruby_version: !ruby/object:Gem::Requirement
192
+ none: false
193
+ requirements:
194
+ - - ! '>='
195
+ - !ruby/object:Gem::Version
196
+ version: '0'
197
+ required_rubygems_version: !ruby/object:Gem::Requirement
198
+ none: false
199
+ requirements:
200
+ - - ! '>='
201
+ - !ruby/object:Gem::Version
202
+ version: '0'
211
203
  requirements: []
212
-
213
204
  rubyforge_project:
214
- rubygems_version: 1.3.6
205
+ rubygems_version: 1.8.23
215
206
  signing_key:
216
207
  specification_version: 3
217
208
  summary: capistrano deployment task for my projects
218
209
  test_files: []
219
-
210
+ has_rdoc: