capistrano-play 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -33,94 +33,91 @@ module Capistrano
33
33
  # without this, there are problems with sudo on remote server
34
34
  default_run_options[:pty] = true
35
35
 
36
- namespace :deploy do
37
- task :start, :roles => :app, :except => { :no_release => true } do
38
- play.start
39
- end
36
+ namespace(:deploy) {
37
+ task(:start, :roles => :app, :except => { :no_release => true }) {
38
+ find_and_execute_task("play:start")
39
+ }
40
40
 
41
- task :restart, :roles => :app, :except => { :no_release => true } do
42
- play.restart
43
- end
41
+ task(:restart, :roles => :app, :except => { :no_release => true }) {
42
+ find_and_execute_task("play:restart")
43
+ }
44
44
 
45
- task :stop, :roles => :app, :except => { :no_release => true } do
46
- play.stop
47
- end
48
- end
45
+ task(:stop, :roles => :app, :except => { :no_release => true }) {
46
+ find_and_execute_task("play:stop")
47
+ }
48
+ }
49
49
 
50
50
  after 'deploy:setup', 'play:setup'
51
51
  after 'deploy:finalize_update', 'play:update'
52
52
 
53
- namespace :play do
54
- _cset :play_version, '1.2.5'
55
- _cset :play_major_version do
53
+ namespace(:play) {
54
+ _cset(:play_version, '1.2.5')
55
+ _cset(:play_major_version) {
56
56
  play_version.scan(/\d+/).first.to_i
57
- end
58
- _cset :play_zip_url do
57
+ }
58
+ _cset(:play_zip_url) {
59
59
  "http://download.playframework.org/releases/#{File.basename(play_zip_file)}"
60
- end
61
- _cset :play_preserve_zip, true
62
- _cset :play_zip_file do
60
+ }
61
+ _cset(:play_preserve_zip, true)
62
+ _cset(:play_zip_file) {
63
63
  File.join(shared_path, 'tools', 'play', "play-#{play_version}.zip")
64
- end
65
- _cset :play_path do
64
+ }
65
+ _cset(:play_path) {
66
66
  File.join(shared_path, 'tools', 'play', "play-#{play_version}")
67
- end
68
- _cset :play_bin do
67
+ }
68
+ _cset(:play_bin) {
69
69
  File.join(play_path, 'play')
70
- end
71
- _cset :play_cmd do
70
+ }
71
+ _cset(:play_cmd) {
72
72
  if fetch(:play_java_home, nil)
73
73
  "env JAVA_HOME=#{play_java_home} #{play_bin}"
74
74
  else
75
75
  play_bin
76
76
  end
77
- end
78
- _cset :play_daemonize_method, :play
79
- _cset :play_daemon do
80
- daemonize.__send__(play_daemonize_method)
81
- end
82
- _cset :play_pid_file do
77
+ }
78
+ _cset(:play_daemonize_method, :play)
79
+ _cset(:play_pid_file) {
83
80
  fetch(:app_pid, File.join(shared_path, 'pids', 'server.pid')) # for backward compatibility
84
- end
85
- _cset :play_use_precompile, true # performe precompilation before restarting service if true
81
+ }
82
+ _cset(:play_use_precompile, true) # performe precompilation before restarting service if true
86
83
 
87
- _cset :play_zip_file_local do
84
+ _cset(:play_zip_file_local) {
88
85
  File.join(File.expand_path('.'), 'tools', 'play', "play-#{play_version}.zip")
89
- end
90
- _cset :play_path_local do
86
+ }
87
+ _cset(:play_path_local) {
91
88
  File.join(File.expand_path('.'), 'tools', 'play', "play-#{play_version}")
92
- end
93
- _cset :play_bin_local do
89
+ }
90
+ _cset(:play_bin_local) {
94
91
  File.join(play_path_local, 'play')
95
- end
96
- _cset :play_cmd_local do
92
+ }
93
+ _cset(:play_cmd_local) {
97
94
  if fetch(:play_java_home_local, nil)
98
95
  "env JAVA_HOME=#{play_java_home_local} #{play_bin_local}"
99
96
  else
100
97
  play_bin_local
101
98
  end
102
- end
103
- _cset :play_project_path do
99
+ }
100
+ _cset(:play_project_path) {
104
101
  release_path
105
- end
106
- _cset :play_project_path_local do
102
+ }
103
+ _cset(:play_project_path_local) {
107
104
  File.expand_path('.')
108
- end
109
- _cset :play_target_path do
105
+ }
106
+ _cset(:play_target_path) {
110
107
  if play_major_version < 2
111
108
  File.join(play_project_path, 'precompiled')
112
109
  else
113
110
  File.join(play_project_path, 'target')
114
111
  end
115
- end
116
- _cset :play_target_path_local do
112
+ }
113
+ _cset(:play_target_path_local) {
117
114
  if play_major_version < 2
118
115
  File.join(play_project_path_local, 'precompiled')
119
116
  else
120
117
  File.join(play_project_path_local, 'target')
121
118
  end
122
- end
123
- _cset :play_dependencies_path_map do
119
+ }
120
+ _cset(:play_dependencies_path_map) {
124
121
  if play_major_version < 2
125
122
  {
126
123
  File.join(play_project_path, 'lib') => File.join(play_project_path_local, 'lib'),
@@ -131,84 +128,84 @@ module Capistrano
131
128
  play_target_path => play_target_path_local,
132
129
  }
133
130
  end
134
- end
135
- _cset :play_subcmd_dependencies do
131
+ }
132
+ _cset(:play_subcmd_dependencies) {
136
133
  if play_major_version < 2
137
134
  "dependencies --forProd --sync"
138
135
  else
139
136
  "dependencies"
140
137
  end
141
- end
142
- _cset :play_subcmd_precompile do
138
+ }
139
+ _cset(:play_subcmd_precompile) {
143
140
  if play_major_version < 2
144
141
  "precompile"
145
142
  else
146
143
  "compile"
147
144
  end
148
- end
149
- _cset :play_precompile_locally, false # perform precompilation on localhost
145
+ }
146
+ _cset(:play_precompile_locally, false) # perform precompilation on localhost
150
147
 
151
- desc "install play if needed"
152
- task :setup do
148
+ desc("install play if needed")
149
+ task(:setup) {
153
150
  transaction {
154
151
  setup_ivy if fetch(:play_setup_ivy, false)
155
152
  install
156
153
  setup_locally if play_precompile_locally
157
154
  }
158
155
  transaction {
159
- play_daemon.setup
156
+ find_and_execute_task("play:daemonize:#{play_daemonize_method}:setup") if play_daemonize_method
160
157
  }
161
- end
158
+ }
162
159
 
163
- task :setup_locally do
160
+ task(:setup_locally) {
164
161
  transaction {
165
162
  setup_ivy_locally if fetch(:play_setup_ivy_locally, false)
166
163
  install_locally
167
164
  }
168
- end
165
+ }
169
166
 
170
- _cset :play_ivy_settings_template, File.join(File.dirname(__FILE__), 'templates', 'ivysettings.erb')
171
- _cset :play_ivy_settings do
167
+ _cset(:play_ivy_settings_template, File.join(File.dirname(__FILE__), 'templates', 'ivysettings.erb'))
168
+ _cset(:play_ivy_settings) {
172
169
  File.join(capture('echo $HOME').chomp, '.ivy2', 'ivysettings.xml')
173
- end
174
- task :setup_ivy, :roles => :app, :except => { :no_release => true } do
170
+ }
171
+ task(:setup_ivy, :roles => :app, :except => { :no_release => true }) {
175
172
  tempfile = File.join('/tmp', File.basename(play_ivy_settings))
176
173
  on_rollback {
177
- run "rm -f #{tempfile}"
174
+ run("rm -f #{tempfile}")
178
175
  }
179
176
  template = File.read(play_ivy_settings_template)
180
177
  result = ERB.new(template).result(binding)
181
- run(<<-EOS)
178
+ run((<<-EOS).gsub(/\s+/, ' '))
182
179
  ( test -d #{File.dirname(play_ivy_settings)} || mkdir -p #{File.dirname(play_ivy_settings)} ) &&
183
180
  ( test -f #{play_ivy_settings} && mv -f #{play_ivy_settings} #{play_ivy_settings}.orig; true );
184
181
  EOS
185
182
  put result, tempfile
186
- run "diff #{play_ivy_settings} #{tempfile} || mv -f #{tempfile} #{play_ivy_settings}"
187
- end
183
+ run("diff #{play_ivy_settings} #{tempfile} || mv -f #{tempfile} #{play_ivy_settings}")
184
+ }
188
185
 
189
- _cset :play_ivy_settings_local, File.join(ENV['HOME'], '.ivy2', 'ivysettings.xml')
190
- task :setup_ivy_locally, :except => { :no_release => true } do
186
+ _cset(:play_ivy_settings_local, File.join(ENV['HOME'], '.ivy2', 'ivysettings.xml'))
187
+ task(:setup_ivy_locally, :except => { :no_release => true }) {
191
188
  template = File.read(play_ivy_settings_template)
192
189
  result = ERB.new(template).result(binding)
193
- run_locally(<<-EOS)
190
+ run_locally((<<-EOS).gsub(/\s+/, ' '))
194
191
  ( test -d #{File.dirname(play_ivy_settings_local)} || mkdir -p #{File.dirname(play_ivy_settings_local)} ) &&
195
192
  ( test -f #{play_ivy_settings_local} && mv -f #{play_ivy_settings_local} #{play_ivy_settings_local}.orig; true );
196
193
  EOS
197
194
  File.open(play_ivy_settings_local, 'w') { |fp| fp.write(result) }
198
- end
195
+ }
199
196
 
200
- task :install, :roles => :app, :except => { :no_release => true } do
197
+ task(:install, :roles => :app, :except => { :no_release => true }) {
201
198
  temp_zip = File.join('/tmp', File.basename(play_zip_file))
202
199
  temp_dir = File.join('/tmp', File.basename(play_zip_file, '.zip'))
203
200
  on_rollback {
204
201
  files = [ play_path, temp_zip, temp_dir ]
205
202
  files << play_zip_file unless play_preserve_zip
206
- run "#{try_sudo} rm -rf #{files.join(' ')}"
203
+ run("#{try_sudo} rm -rf #{files.join(' ')}")
207
204
  }
208
- run "#{try_sudo} rm -f #{play_zip_file}" unless play_preserve_zip
205
+ run("#{try_sudo} rm -f #{play_zip_file}") unless play_preserve_zip
209
206
 
210
207
  dirs = [ File.dirname(play_zip_file), File.dirname(play_path) ].uniq()
211
- run(<<-EOS)
208
+ run((<<-EOS).gsub(/\s+/, ' '))
212
209
  if ! test -x #{play_bin}; then
213
210
  mkdir -p #{dirs.join(' ')} &&
214
211
  ( test -f #{play_zip_file} || ( wget --no-verbose -O #{temp_zip} #{play_zip_url} && #{try_sudo} mv -f #{temp_zip} #{play_zip_file}; true ) ) &&
@@ -216,16 +213,16 @@ module Capistrano
216
213
  test -x #{play_bin};
217
214
  fi;
218
215
  EOS
219
- run "#{try_sudo} rm -f #{play_zip_file}" unless play_preserve_zip
220
- end
221
-
222
- task :install_locally, :except => { :no_release => true } do
216
+ run("#{try_sudo} rm -f #{play_zip_file}") unless play_preserve_zip
217
+ }
218
+
219
+ task(:install_locally, :except => { :no_release => true }) {
223
220
  on_rollback {
224
221
  files = [ play_path_local, play_zip_file_local ]
225
222
  run_locally("rm -rf #{files.join(' ')}")
226
223
  }
227
224
  dirs = [ File.dirname(play_zip_file_local), File.dirname(play_path_local) ].uniq()
228
- run_locally(<<-EOS)
225
+ run_locally((<<-EOS).gsub(/\s+/, ' '))
229
226
  if ! test -x #{play_bin_local}; then
230
227
  mkdir -p #{dirs.join(' ')} &&
231
228
  ( test -f #{play_zip_file_local} || ( wget --no-verbose -O #{play_zip_file_local} #{play_zip_url} ) ) &&
@@ -233,93 +230,93 @@ module Capistrano
233
230
  test -x #{play_bin_local};
234
231
  fi;
235
232
  EOS
236
- end
233
+ }
237
234
 
238
- namespace :daemonize do
239
- namespace :play do
240
- task :setup, :roles => :app, :except => { :no_release => true } do
235
+ namespace(:daemonize) {
236
+ namespace(:play) {
237
+ task(:setup, :roles => :app, :except => { :no_release => true }) {
241
238
  # nop
242
- end
239
+ }
243
240
 
244
- _cset :play_start_options do
241
+ _cset(:play_start_options) {
245
242
  options = []
246
243
  options << "-Xss2048k"
247
244
  options << "--%prod"
248
245
  options
249
- end
250
- task :start, :roles => :app, :except => { :no_release => true } do
251
- run "rm -f #{play_pid_file}" # FIXME: should check if the pid is active
246
+ }
247
+ task(:start, :roles => :app, :except => { :no_release => true }) {
248
+ run("rm -f #{play_pid_file}") # FIXME: should check if the pid is active
252
249
  play_start_options << "-Dprecompiled=true" if play_use_precompile
253
- run "cd #{play_project_path} && nohup #{play_cmd} start --pid_file=#{play_pid_file} #{play_start_options.join(' ')}"
254
- end
250
+ run("cd #{play_project_path} && nohup #{play_cmd} start --pid_file=#{play_pid_file} #{play_start_options.join(' ')}")
251
+ }
255
252
 
256
- task :stop, :roles => :app, :except => { :no_release => true } do
257
- run "cd #{play_project_path} && #{play_cmd} stop --pid_file=#{play_pid_file}"
258
- end
253
+ task(:stop, :roles => :app, :except => { :no_release => true }) {
254
+ run("cd #{play_project_path} && #{play_cmd} stop --pid_file=#{play_pid_file}")
255
+ }
259
256
 
260
- task :restart, :roles => :app, :except => { :no_release => true } do
257
+ task(:restart, :roles => :app, :except => { :no_release => true }) {
261
258
  stop
262
259
  start
263
- end
260
+ }
264
261
 
265
- task :status, :roles => :app, :except => { :no_release => true } do
266
- run "cd #{play_project_path} && #{play_cmd} status --pid_file=#{play_pid_file}"
267
- end
268
- end
262
+ task(:status, :roles => :app, :except => { :no_release => true }) {
263
+ run("cd #{play_project_path} && #{play_cmd} status --pid_file=#{play_pid_file}")
264
+ }
265
+ }
269
266
 
270
- namespace :upstart do
271
- _cset :play_upstart_service do
267
+ namespace(:upstart) {
268
+ _cset(:play_upstart_service) {
272
269
  application
273
- end
274
- _cset :play_upstart_config do
270
+ }
271
+ _cset(:play_upstart_config) {
275
272
  File.join('/etc', 'init', "#{play_upstart_service}.conf")
276
- end
277
- _cset :play_upstart_config_template, File.join(File.dirname(__FILE__), 'templates', 'upstart.erb')
278
- _cset :play_upstart_options do
273
+ }
274
+ _cset(:play_upstart_config_template, File.join(File.dirname(__FILE__), 'templates', 'upstart.erb'))
275
+ _cset(:play_upstart_options) {
279
276
  options = []
280
277
  options << "-Xss2048k"
281
278
  options << "--%prod"
282
279
  options
283
- end
284
- _cset :play_upstart_runner do
280
+ }
281
+ _cset(:play_upstart_runner) {
285
282
  user
286
- end
283
+ }
287
284
 
288
- task :setup, :roles => :app, :except => { :no_release => true } do
285
+ task(:setup, :roles => :app, :except => { :no_release => true }) {
289
286
  tempfile = File.join('/tmp', File.basename(play_upstart_config))
290
287
  on_rollback {
291
- run "rm -f #{tempfile}"
288
+ run("rm -f #{tempfile}")
292
289
  }
293
290
  play_upstart_options << "-Dprecompiled=true" if play_use_precompile
294
291
  template = File.read(play_upstart_config_template)
295
292
  result = ERB.new(template).result(binding)
296
293
  put result, tempfile
297
- run "diff #{play_upstart_config} #{tempfile} || #{sudo} mv -f #{tempfile} #{play_upstart_config}"
298
- end
294
+ run("diff #{play_upstart_config} #{tempfile} || #{sudo} mv -f #{tempfile} #{play_upstart_config}")
295
+ }
299
296
 
300
- task :start, :roles => :app, :except => { :no_release => true } do
301
- run "#{sudo} service #{play_upstart_service} start"
302
- end
297
+ task(:start, :roles => :app, :except => { :no_release => true }) {
298
+ run("#{sudo} service #{play_upstart_service} start")
299
+ }
303
300
 
304
- task :stop, :roles => :app, :except => { :no_release => true } do
305
- run "#{sudo} service #{play_upstart_service} stop"
306
- end
301
+ task(:stop, :roles => :app, :except => { :no_release => true }) {
302
+ run("#{sudo} service #{play_upstart_service} stop")
303
+ }
307
304
 
308
- task :restart, :roles => :app, :except => { :no_release => true } do
309
- run "#{sudo} service #{play_upstart_service} restart || #{sudo} service #{play_upstart_service} start"
310
- end
305
+ task(:restart, :roles => :app, :except => { :no_release => true }) {
306
+ run("#{sudo} service #{play_upstart_service} restart || #{sudo} service #{play_upstart_service} start")
307
+ }
311
308
 
312
- task :status, :roles => :app, :except => { :no_release => true } do
313
- run "#{sudo} service #{play_upstart_service} status"
314
- end
315
- end
316
- end
309
+ task(:status, :roles => :app, :except => { :no_release => true }) {
310
+ run("#{sudo} service #{play_upstart_service} status")
311
+ }
312
+ }
313
+ }
317
314
 
318
- desc "update play runtime environment"
319
- task :update, :roles => :app, :except => { :no_release => true } do
315
+ desc("update play runtime environment")
316
+ task(:update, :roles => :app, :except => { :no_release => true }) {
320
317
  if play_major_version < 2
321
318
  # FIXME: made tmp/ group writable since deploy:finalize_update creates non-group-writable tmp/
322
- run "#{try_sudo} chmod g+w #{play_project_path}/tmp" if fetch(:group_writable, true)
319
+ run("mkdir -p #{play_project_path}/tmp; #{try_sudo} chmod g+w #{play_project_path}/tmp") if fetch(:group_writable, true)
323
320
  end
324
321
 
325
322
  if play_use_precompile
@@ -337,95 +334,99 @@ module Capistrano
337
334
  else
338
335
  dependencies
339
336
  end
340
- end
337
+ }
341
338
 
342
- task :dependencies, :roles => :app, :except => { :no_release => true } do
343
- run "cd #{play_project_path} && #{play_cmd} #{play_subcmd_dependencies}"
344
- end
339
+ task(:dependencies, :roles => :app, :except => { :no_release => true }) {
340
+ run("cd #{play_project_path} && #{play_cmd} #{play_subcmd_dependencies}")
341
+ }
345
342
 
346
- task :dependencies_locally, :roles => :app, :except => { :no_release => true } do
343
+ task(:dependencies_locally, :roles => :app, :except => { :no_release => true }) {
347
344
  if dry_run
348
345
  logger.info("resolving play dependencies locally: #{play_project_path_local}")
349
346
  else
347
+ logger.debug("cd #{play_project_path_local} && #{play_cmd_local} #{play_subcmd_dependencies}")
350
348
  abort("error on resolving play dependencies.") unless system("cd #{play_project_path_local} && #{play_cmd_local} #{play_subcmd_dependencies}")
351
349
  end
352
- end
350
+ }
353
351
 
354
- task :precompile, :roles => :app, :except => { :no_release => true } do
355
- run "cd #{play_project_path} && #{play_cmd} #{play_subcmd_precompile}"
356
- end
352
+ task(:precompile, :roles => :app, :except => { :no_release => true }) {
353
+ run("cd #{play_project_path} && #{play_cmd} #{play_subcmd_precompile}")
354
+ }
357
355
 
358
- task :precompile_locally, :roles => :app, :except => { :no_release => true } do
356
+ task(:precompile_locally, :roles => :app, :except => { :no_release => true }) {
359
357
  on_rollback {
360
358
  run_locally("cd #{play_project_path_local} && #{play_cmd_local} clean")
361
359
  }
362
360
  if dry_run
363
361
  logger.info("compiling play application locally: #{play_project_path_local}")
364
362
  else
363
+ logger.debug("cd #{play_project_path_local} && #{play_cmd_local} #{play_subcmd_precompile}")
365
364
  abort("error on resolving play dependencies.") unless system("cd #{play_project_path_local} && #{play_cmd_local} #{play_subcmd_precompile}")
366
365
  end
367
- end
368
-
369
- task :upload_locally, :roles => :app, :except => { :no_release => true } do
370
- map = play_dependencies_path_map.merge(play_target_path => play_target_path_local)
371
- run "mkdir -p #{map.keys.join(' ')}"
372
- map.map { |dst, src|
373
- run_locally "cd #{File.dirname(src)} && tar chzf #{src}.tar.gz #{File.basename(src)}" unless dry_run
374
- upload "#{src}.tar.gz", "#{dst}.tar.gz"
375
- run "cd #{File.dirname(dst)} && tar xzf #{dst}.tar.gz && rm #{dst}.tar.gz"
366
+ }
367
+
368
+ task(:upload_locally, :roles => :app, :except => { :no_release => true }) {
369
+ play_dependencies_path_map.merge(play_target_path => play_target_path_local).each { |dst, src|
370
+ begin
371
+ run_locally("mkdir -p #{src} && cd #{File.dirname(src)} && tar chzf #{src}.tar.gz #{File.basename(src)}") unless dry_run
372
+ upload "#{src}.tar.gz", "#{dst}.tar.gz"
373
+ run("mkdir -p #{File.dirname(dst)} && cd #{File.dirname(dst)} && tar xzf #{dst}.tar.gz && rm -f #{dst}.tar.gz")
374
+ run("chmod -R g+w #{dst}") if fetch(:group_writable, true)
375
+ ensure
376
+ run_locally("rm -f #{src}.tar.gz") rescue nil unless dry_run
377
+ end
376
378
  }
377
- run "chmod -R g+w #{map.keys.join(' ')}" if fetch(:group_writable, true)
378
- end
379
-
380
- desc "start play service"
381
- task :start, :roles => :app, :except => { :no_release => true } do
382
- play_daemon.start
383
- end
384
-
385
- desc "stop play service"
386
- task :stop, :roles => :app, :except => { :no_release => true } do
387
- play_daemon.stop
388
- end
389
-
390
- desc "restart play service"
391
- task :restart, :roles => :app, :except => { :no_release => true } do
392
- play_daemon.restart
393
- end
394
-
395
- desc "view play status"
396
- task :status, :roles => :app, :except => { :no_release => true } do
397
- play_daemon.status
398
- end
399
-
400
- desc "view play pid"
401
- task :pid, :roles => :app, :except => { :no_release => true } do
402
- run "cd #{play_project_path} && #{play_cmd} pid --pid_file=#{play_pid_file}"
403
- end
404
-
405
- desc "view play version"
406
- task :version, :roles => :app, :except => { :no_release => true } do
407
- run "cd #{play_project_path} && #{play_cmd} version --pid_file=#{play_pid_file}"
408
- end
409
-
410
- desc "view running play apps"
411
- task :ps, :roles => :app, :except => { :no_release => true } do
412
- run "ps -eaf | grep 'play'"
413
- end
414
-
415
- desc "kill play processes"
416
- task :kill, :roles => :app, :except => { :no_release => true } do
417
- run "ps -ef | grep 'play' | grep -v 'grep' | awk '{print $2}'| xargs -i kill {} ; echo ''"
418
- end
419
-
420
- desc "view logfiles"
421
- task :logs, :roles => :app, :except => { :no_release => true } do
422
- run "tail -f #{shared_path}/log/#{application}.log" do |channel, stream, data|
379
+ }
380
+
381
+ desc("start play service")
382
+ task(:start, :roles => :app, :except => { :no_release => true }) {
383
+ find_and_execute_task("play:daemon:#{play_daemonize_method}:start") if play_daemonize_method
384
+ }
385
+
386
+ desc("stop play service")
387
+ task(:stop, :roles => :app, :except => { :no_release => true }) {
388
+ find_and_execute_task("play:daemon:#{play_daemonize_method}:stop") if play_daemonize_method
389
+ }
390
+
391
+ desc("restart play service")
392
+ task(:restart, :roles => :app, :except => { :no_release => true }) {
393
+ find_and_execute_task("play:daemon:#{play_daemonize_method}:restart") if play_daemonize_method
394
+ }
395
+
396
+ desc("view play status")
397
+ task(:status, :roles => :app, :except => { :no_release => true }) {
398
+ find_and_execute_task("play:daemon:#{play_daemonize_method}:status") if play_daemonize_method
399
+ }
400
+
401
+ desc("view play pid")
402
+ task(:pid, :roles => :app, :except => { :no_release => true }) {
403
+ run("cd #{play_project_path} && #{play_cmd} pid --pid_file=#{play_pid_file}")
404
+ }
405
+
406
+ desc("view play version")
407
+ task(:version, :roles => :app, :except => { :no_release => true }) {
408
+ run("cd #{play_project_path} && #{play_cmd} version --pid_file=#{play_pid_file}")
409
+ }
410
+
411
+ desc("view running play apps")
412
+ task(:ps, :roles => :app, :except => { :no_release => true }) {
413
+ run("ps -eaf | grep 'play'")
414
+ }
415
+
416
+ desc("kill play processes")
417
+ task(:kill, :roles => :app, :except => { :no_release => true }) {
418
+ run("ps -ef | grep 'play' | grep -v 'grep' | awk '{print $2}'| xargs -i kill {} ; echo ''")
419
+ }
420
+
421
+ desc("view logfiles")
422
+ task(:logs, :roles => :app, :except => { :no_release => true }) {
423
+ run("tail -f #{shared_path}/log/#{application}.log") do |channel, stream, data|
423
424
  puts # for an extra line break before the host name
424
425
  puts "#{channel[:host]}: #{data}"
425
426
  break if stream == :err
426
427
  end
427
- end
428
- end
428
+ }
429
+ }
429
430
  }
430
431
  end
431
432
  end
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Play
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-play
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
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: 2012-09-04 00:00:00.000000000 Z
12
+ date: 2012-10-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capistrano