crapapult 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/lib/crapapult.rb +28 -3
  3. metadata +4 -4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.6
1
+ 0.0.7
data/lib/crapapult.rb CHANGED
@@ -74,17 +74,41 @@ Capistrano::Configuration.instance(:must_exist).load do
74
74
 
75
75
  # Defines an application with an optional owner, group, and configuration
76
76
  # block.
77
- def application(name, owner=name, group=owner, &block)
77
+ def application(name, opts={}, &block)
78
78
  app_block = block || lambda {}
79
79
  set :application_name, name
80
- set :owner, owner
81
- set :owner_group, group
80
+ set :owner, opts[:owner] || name
81
+ set :owner_group, opts[:group] || name
82
+ set :healthcheck_url, opts[:healthcheck]
82
83
  namespace :deploy do
83
84
  task :configure do
84
85
  setup
85
86
  puts "> Configuring the application"
86
87
  app_block.call
87
88
  end
89
+
90
+ if opts[:healthcheck]
91
+ task :verify do
92
+ puts("> Verifying")
93
+ for server in roles[:app].servers
94
+ uri = URI.parse(erb(healthcheck_url))
95
+ req = Net::HTTP::Get.new(uri.path)
96
+ Net::HTTP.start(uri.host, uri.port) do |http|
97
+ resp = http.request(req)
98
+ if resp.code.to_i == 200
99
+ puts(">> #{server.host} is OK")
100
+ else
101
+ puts(">> #{server.host} is DOWN!!!")
102
+ puts(resp.body.split("\n").map { |s| ">>> #{s}" }.join)
103
+ end
104
+ end
105
+ end
106
+ end
107
+ else
108
+ task :verify do
109
+ puts("> No healthcheck configured for the application. Hope it's running.")
110
+ end
111
+ end
88
112
  end
89
113
  end
90
114
 
@@ -171,6 +195,7 @@ Capistrano::Configuration.instance(:must_exist).load do
171
195
  configure
172
196
  symlink
173
197
  restart
198
+ verify
174
199
  cleanup
175
200
 
176
201
  puts "> Successfully deployed the #{current_branch} branch to #{current_environment}! Congrats!"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crapapult
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 6
10
- version: 0.0.6
9
+ - 7
10
+ version: 0.0.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Coda Hale
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-09 00:00:00 -07:00
18
+ date: 2011-05-10 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency