gaptool-server 0.3.6 → 0.3.7

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.6
1
+ 0.3.7
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "gaptool-server"
8
- s.version = "0.3.6"
8
+ s.version = "0.3.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Matt Bailey"]
data/lib/app.rb CHANGED
@@ -14,6 +14,13 @@ class GaptoolServer < Sinatra::Application
14
14
  enable :raise_errors
15
15
  enable :dump_errors
16
16
 
17
+ error do
18
+ content_type :json
19
+ status 500
20
+
21
+ {:result => 'error', :message => env['sinatra.error'].message}.to_json
22
+ end
23
+
17
24
  before do
18
25
  error 401 unless $redis.hget('users', env['HTTP_X_GAPTOOL_USER']) == env['HTTP_X_GAPTOOL_KEY']
19
26
  error 401 unless env['HTTP_X_GAPTOOL_USER'] && env['HTTP_X_GAPTOOL_KEY']
data/lib/routes/main.rb CHANGED
@@ -75,14 +75,10 @@ class GaptoolServer < Sinatra::Application
75
75
  data = JSON.parse request.body.read
76
76
  AWS.config(:access_key_id => $redis.hget('config', 'aws_id'), :secret_access_key => $redis.hget('config', 'aws_secret'), :ec2_endpoint => "ec2.#{data['zone']}.amazonaws.com")
77
77
  @ec2 = AWS::EC2.new
78
- begin
79
- @instance = @ec2.instances[data['id']]
80
- res = @instance.terminate
81
- res = $redis.del($redis.keys("*#{data['id']}"))
82
- out = {data['id'] => {'status'=> 'terminated'}}
83
- rescue
84
- error 404
85
- end
78
+ @instance = @ec2.instances[data['id']]
79
+ res = @instance.terminate
80
+ res = $redis.del($redis.keys("*#{data['id']}"))
81
+ out = {data['id'] => {'status'=> 'terminated'}}
86
82
  out.to_json
87
83
  end
88
84
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: gaptool-server
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.3.6
5
+ version: 0.3.7
6
6
  platform: ruby
7
7
  authors:
8
8
  - Matt Bailey
@@ -233,7 +233,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
233
233
  requirements:
234
234
  - - ">="
235
235
  - !ruby/object:Gem::Version
236
- hash: 4255522910746715047
236
+ hash: -3957808604451578110
237
237
  segments:
238
238
  - 0
239
239
  version: "0"