jflow 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jflow.rb +15 -0
- data/lib/jflow/activity/task.rb +1 -8
- data/lib/jflow/activity/worker.rb +2 -1
- data/lib/jflow/cli.rb +8 -3
- data/lib/jflow/termination_protector.rb +12 -4
- data/lib/jflow/version.rb +1 -1
- metadata +35 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7114166aa1644ef7562c3d6060f8e3ef7d9674f0
|
4
|
+
data.tar.gz: 43957bc2f311ef683b3d02acbf2f90f13fa808f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a08dedc85116cc5b91dc87cce3b3c78cb76f700e1cf187cf43086b331c6d32b3e288290f21084e8040085699825d34efaa482937e03d1bf5064d21124ba1ce9
|
7
|
+
data.tar.gz: b51304ab2e19f526f736454e532f848a96c930b4ba49a80693eaed5a2ea992489cf3f4da0c88b11ccfa568a63d896d4d9e8d4fb53251421206cdf683fe956fe2
|
data/lib/jflow.rb
CHANGED
@@ -39,4 +39,19 @@ module JFlow
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
42
|
+
|
43
|
+
def self.handle_exception(exception)
|
44
|
+
JFlow.configuration.error_handlers.each do |error_handler|
|
45
|
+
begin
|
46
|
+
error_handler.call(exception)
|
47
|
+
rescue => e
|
48
|
+
log_error("Error handler failed!")
|
49
|
+
log_error(e.backtrace.join("\n")) unless e.backtrace.nil?
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.log_error(str)
|
55
|
+
JFlow.configuration.logger.error "[#{Thread.current.object_id}] #{str}"
|
56
|
+
end
|
42
57
|
end
|
data/lib/jflow/activity/task.rb
CHANGED
@@ -92,14 +92,7 @@ module JFlow
|
|
92
92
|
end
|
93
93
|
|
94
94
|
def handle_exception(exception)
|
95
|
-
JFlow.
|
96
|
-
begin
|
97
|
-
error_handler.call(exception)
|
98
|
-
rescue => e
|
99
|
-
log_error("Error handler failed!")
|
100
|
-
log_error(e.backtrace.join("\n")) unless e.backtrace.nil?
|
101
|
-
end
|
102
|
-
end
|
95
|
+
JFlow.handle_exception(exception)
|
103
96
|
end
|
104
97
|
|
105
98
|
private
|
@@ -45,6 +45,7 @@ module JFlow
|
|
45
45
|
Thread.current.set_state(:working)
|
46
46
|
task.run!
|
47
47
|
rescue => exception
|
48
|
+
Thread.current.set_state(:polling)
|
48
49
|
task.handle_exception(exception)
|
49
50
|
task.failed!(exception)
|
50
51
|
end
|
@@ -76,4 +77,4 @@ module JFlow
|
|
76
77
|
|
77
78
|
end
|
78
79
|
end
|
79
|
-
end
|
80
|
+
end
|
data/lib/jflow/cli.rb
CHANGED
@@ -70,9 +70,14 @@ module JFlow
|
|
70
70
|
protector = JFlow::TerminationProtector.new
|
71
71
|
loop do
|
72
72
|
break if Thread.current.marked_for_shutdown?
|
73
|
-
|
74
|
-
|
75
|
-
|
73
|
+
begin
|
74
|
+
protector.set_protection(should_protect?) if is_ec2_instance?
|
75
|
+
stats.tick if enable_stats
|
76
|
+
sleep 30
|
77
|
+
rescue => e
|
78
|
+
JFlow.handle_exception(e)
|
79
|
+
sleep 180
|
80
|
+
end
|
76
81
|
end
|
77
82
|
end
|
78
83
|
end
|
@@ -1,9 +1,15 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
require 'json'
|
3
|
-
|
4
3
|
module JFlow
|
5
4
|
class TerminationProtector
|
6
5
|
|
6
|
+
attr_accessor :asg_client, :ec2_client
|
7
|
+
|
8
|
+
def initialize(asg_client = nil, ec2_client = nil)
|
9
|
+
@asg_client = asg_client || Aws::AutoScaling::Client.new(region: region, credentials: Aws::InstanceProfileCredentials.new)
|
10
|
+
@ec2_client = ec2_client || Aws::EC2::Client.new(region: region, credentials: Aws::InstanceProfileCredentials.new)
|
11
|
+
end
|
12
|
+
|
7
13
|
def region
|
8
14
|
instance_data['region']
|
9
15
|
end
|
@@ -18,7 +24,6 @@ module JFlow
|
|
18
24
|
end
|
19
25
|
|
20
26
|
def get_asg_name
|
21
|
-
ec2_client = Aws::EC2::Client.new(region: region, credentials: Aws::InstanceProfileCredentials.new)
|
22
27
|
instance_tags = ec2_client.describe_tags(filters: [
|
23
28
|
{
|
24
29
|
name: "resource-id",
|
@@ -32,9 +37,12 @@ module JFlow
|
|
32
37
|
end
|
33
38
|
|
34
39
|
def set_protection(protect_status)
|
40
|
+
@previous_protect_status ||= false
|
41
|
+
return if @previous_protect_status == protect_status
|
42
|
+
@previous_protect_status = protect_status
|
43
|
+
|
35
44
|
JFlow.configuration.logger.debug "Setting termination protection status to #{protect_status} for instance #{instance_id} in region #{region}"
|
36
45
|
begin
|
37
|
-
asg_client = Aws::AutoScaling::Client.new(region: region, credentials: Aws::InstanceProfileCredentials.new)
|
38
46
|
asg_client.set_instance_protection({
|
39
47
|
instance_ids: [instance_id],
|
40
48
|
auto_scaling_group_name: get_asg_name,
|
@@ -42,8 +50,8 @@ module JFlow
|
|
42
50
|
})
|
43
51
|
rescue => e
|
44
52
|
JFlow.configuration.logger.debug "Something went wrong setting termination proection: #{e.inspect}"
|
53
|
+
JFlow.handle_exception(e)
|
45
54
|
end
|
46
55
|
end
|
47
|
-
|
48
56
|
end
|
49
57
|
end
|
data/lib/jflow/version.rb
CHANGED
metadata
CHANGED
@@ -1,114 +1,114 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jflow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christophe Verbinnen
|
8
8
|
- Richard Vorp
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-08-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk
|
16
|
-
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '2'
|
21
|
-
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
24
|
requirements:
|
23
25
|
- - "~>"
|
24
26
|
- !ruby/object:Gem::Version
|
25
27
|
version: '2'
|
26
|
-
prerelease: false
|
27
|
-
type: :runtime
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: hash_validator
|
30
|
-
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '0.4'
|
35
|
-
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
36
38
|
requirements:
|
37
39
|
- - "~>"
|
38
40
|
- !ruby/object:Gem::Version
|
39
41
|
version: '0.4'
|
40
|
-
prerelease: false
|
41
|
-
type: :runtime
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: jflow_exceptions
|
44
|
-
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: 0.1.1
|
49
|
-
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
52
|
requirements:
|
51
53
|
- - "~>"
|
52
54
|
- !ruby/object:Gem::Version
|
53
55
|
version: 0.1.1
|
54
|
-
prerelease: false
|
55
|
-
type: :runtime
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: bundler
|
58
|
-
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
60
|
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '1.10'
|
63
|
-
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
64
66
|
requirements:
|
65
67
|
- - "~>"
|
66
68
|
- !ruby/object:Gem::Version
|
67
69
|
version: '1.10'
|
68
|
-
prerelease: false
|
69
|
-
type: :development
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: rake
|
72
|
-
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
74
|
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: '10.0'
|
77
|
-
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
78
80
|
requirements:
|
79
81
|
- - "~>"
|
80
82
|
- !ruby/object:Gem::Version
|
81
83
|
version: '10.0'
|
82
|
-
prerelease: false
|
83
|
-
type: :development
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
85
|
name: rspec
|
86
|
-
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
88
|
- - ">="
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: '0'
|
91
|
-
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
92
94
|
requirements:
|
93
95
|
- - ">="
|
94
96
|
- !ruby/object:Gem::Version
|
95
97
|
version: '0'
|
96
|
-
prerelease: false
|
97
|
-
type: :development
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
99
|
name: simplecov
|
100
|
-
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
102
|
- - ">="
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: '0'
|
105
|
-
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
108
|
requirements:
|
107
109
|
- - ">="
|
108
110
|
- !ruby/object:Gem::Version
|
109
111
|
version: '0'
|
110
|
-
prerelease: false
|
111
|
-
type: :development
|
112
112
|
description: you know, for flow
|
113
113
|
email:
|
114
114
|
- christophe.verbinnen@lookout.com
|
@@ -147,7 +147,7 @@ homepage: https://github.com/djpate/jflow
|
|
147
147
|
licenses: []
|
148
148
|
metadata:
|
149
149
|
allowed_push_host: https://rubygems.org
|
150
|
-
post_install_message:
|
150
|
+
post_install_message:
|
151
151
|
rdoc_options: []
|
152
152
|
require_paths:
|
153
153
|
- lib
|
@@ -162,9 +162,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
162
162
|
- !ruby/object:Gem::Version
|
163
163
|
version: '0'
|
164
164
|
requirements: []
|
165
|
-
rubyforge_project:
|
165
|
+
rubyforge_project:
|
166
166
|
rubygems_version: 2.4.8
|
167
|
-
signing_key:
|
167
|
+
signing_key:
|
168
168
|
specification_version: 4
|
169
169
|
summary: SWF Flow framework for jRuby
|
170
170
|
test_files: []
|
171
|
+
has_rdoc:
|