playframework-capistrano 0.0.3 → 0.0.4

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.
@@ -1,5 +1,5 @@
1
1
  module Playframework
2
2
  class Capistrano
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
@@ -13,71 +13,63 @@ module Capistrano
13
13
  _cset(:application, 'my_application')
14
14
  _cset(:deploy_to, "/var/lib/#{application}")
15
15
 
16
- _cset(:log_dir, '/var/log')
17
-
18
16
  _cset(:prod_conf, 'prod.conf')
19
- _cset(:project_home, '.')
20
17
 
18
+ # https://github.com/capistrano/capistrano/wiki/2.x-DSL-Action-Invocation-Run
19
+ default_run_options[:shell] = '/bin/bash --login'
20
+
21
+ # Hooks
22
+ after "deploy", "playframework:setup", "playframework:package"
21
23
 
22
24
  namespace :playframework do
23
25
  task :setup do
24
- run "mkdir -p #{deploy_to}"
25
- put "#!/bin/bash\nnohup bash -c \"cd #{deploy_to} && target/start $* &>> #{log_dir}/#{application}.log 2>&1\" &> /dev/null &", "#{deploy_to}/start.sh", :mode => '755', :via => :scp
26
- put "#!/bin/bash\npid=`cat RUNNING_PID 2> /dev/null`\nif [ \"$pid\" == \"\" ]; then echo '#{application} is not running'; exit 0; fi\necho 'Stopping #{application}...'\nkill -SIGTERM $pid", "#{deploy_to}/stop.sh", :mode => '755', :via => :scp
26
+ put "#!/bin/bash\nnohup bash -c \"cd #{current_path} && target/start $* &>> #{current_path}/log/#{application}.log 2>&1\" &> /dev/null &", "#{current_path}/start.sh", :mode => '755', :via => :scp
27
+ put "#!/bin/bash\npid=`cat RUNNING_PID 2> /dev/null`\nif [ \"$pid\" == \"\" ]; then echo '#{application} is not running'; exit 0; fi\necho 'Stopping #{application}...'\nkill -SIGTERM $pid", "#{current_path}/stop.sh", :mode => '755', :via => :scp
28
+ put "#!/bin/bash\nexport", "#{current_path}/envvars.sh", :mode => '755', :via => :scp
29
+ end
30
+
31
+ task :envvars do
32
+ run [
33
+ "cd #{current_path}",
34
+ "./envvars.sh"
35
+ ].join(" && ")
27
36
  end
28
37
 
29
- task :deploy_prod, :roles => :prod do
30
- package
31
- stop
32
- copy_app_files
33
- start_prod
38
+ task :tests do
39
+ run [
40
+ "cd #{current_path}",
41
+ "play test"
42
+ ].join(" && ")
34
43
  end
35
44
 
36
- task :deploy_dev, :roles => :dev do
37
- package
38
- stop
39
- copy_app_files
40
- start_dev
45
+ task :package do
46
+ run [
47
+ "cd #{current_path}",
48
+ "play clean compile stage"
49
+ ].join(" && ")
41
50
  end
42
51
 
43
52
  task :stop do
44
- depend :remote, deploy_to
45
- targets = find_servers_for_task(current_task)
46
- failed_targets = targets.map do |target|
47
- cmd = "ssh -p #{port} #{user}@#{target.host} 'cd #{deploy_to} && ./stop.sh'"
48
- target.host unless system cmd
49
- end.compact
50
- raise "Stopping #{application} failed on #{failed_targets.join(',')}" if failed_targets.any?
53
+ run [
54
+ "cd #{current_path}",
55
+ "./stop.sh"
56
+ ].join(" && ")
51
57
  end
52
58
 
53
59
  task :start_prod do
54
- targets = find_servers_for_task(current_task)
55
- failed_targets = targets.map do |target|
56
- cmd = "ssh -p #{port} #{user}@#{target.host} 'cd #{deploy_to} && ./start.sh -Dconfig.resource=#{prod_conf}'"
57
- target.host unless system cmd
58
- end.compact
59
- raise "Starting #{application} failed on #{failed_targets.join(',')}" if failed_targets.any?
60
+ run [
61
+ "cd #{current_path}",
62
+ "./start.sh -Dconfig.resource=#{prod_conf}"
63
+ ].join(" && ")
60
64
  end
61
65
 
62
66
  task :start_dev do
63
- targets = find_servers_for_task(current_task)
64
- failed_targets = targets.map do |target|
65
- cmd = "ssh -p #{port} #{user}@#{target.host} 'cd #{deploy_to} && ./start.sh'"
66
- target.host unless system cmd
67
- end.compact
68
- raise "Starting #{application} failed on #{failed_targets.join(',')}" if failed_targets.any?
67
+ run [
68
+ "cd #{current_path}",
69
+ "./start.sh"
70
+ ].join(" && ")
69
71
  end
70
-
71
- task :package do
72
- system "cd #{project_home} && play clean compile test stage"
73
- raise "Error in package task" if not $?.success?
74
- end
75
-
76
- task :copy_app_files do
77
- run "rm -fr #{deploy_to}/target"
78
- upload "#{project_home}/target", deploy_to, :via => :scp, :recursive => true
79
- end
80
- end # end namespace playframework
72
+ end
81
73
 
82
74
  end if Capistrano.const_defined? :Configuration and Capistrano::Configuration.methods.map(&:to_sym).include? :instance
83
75
  end # end module Capistrano
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: playframework-capistrano
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
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: 2013-05-05 00:00:00.000000000 Z
12
+ date: 2013-05-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capistrano