patriot-workflow-scheduler 0.6.2 → 0.7.0
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.
- checksums.yaml +8 -8
- data/lib/patriot/command.rb +19 -10
- data/lib/patriot/command/base.rb +18 -9
- data/lib/patriot/command/command_group.rb +1 -0
- data/lib/patriot/command/parser.rb +1 -1
- data/lib/patriot/command/post_processor.rb +14 -0
- data/lib/patriot/command/post_processor/base.rb +50 -0
- data/lib/patriot/command/post_processor/mail_notification.rb +59 -0
- data/lib/patriot/command/post_processor/retrial.rb +37 -0
- data/lib/patriot/command/post_processor/skip_on_fail.rb +18 -0
- data/lib/patriot/command/sh_command.rb +1 -1
- data/lib/patriot/job_store.rb +2 -3
- data/lib/patriot/job_store/job.rb +12 -1
- data/lib/patriot/tool/batch_parser.rb +3 -1
- data/lib/patriot/util/config.rb +2 -0
- data/lib/patriot/util/cron_format_parser.rb +7 -5
- data/lib/patriot/util/date_util.rb +1 -1
- data/lib/patriot/worker/base.rb +13 -2
- metadata +21 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MjBkMGRiMGQ3ZGU1MTk0OThiN2VkNjBhYmU3YjA1YjVjMmQ4OGU1Mg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ODMwYTA4NWZhNzQ0MWY1M2ZkZDg0NjI4ZmIwYTA3ZTkzOGRlZTQyZg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YzRkMTVjOThmYTYzYTIxODEwMmNhODNjZGQ1YTBmYzBjYzVjNDhjODg0OTdj
|
10
|
+
NDBkZDZhOTkwNDFhYjM0ZjZlYjlkNzQ4ZWUzMDc1NmU4MWJjMWNkYzc5ZGE1
|
11
|
+
ZWIxNjU1MDJhYTE0MWI1YmQ2YTE3NjE4OTQ0NGFhNzNkZjk4MGU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ODdkZTM5YjliNWI5MDI3YmNkNzVlM2FkNzNkNzg4MDI5YTM0ZDYzNzJkZTc3
|
14
|
+
ODlkMDljNGE1YzA0MWVhNWM4MzAyOTExNDMzNGY1YWEyOGU5YzdhM2M1YTc1
|
15
|
+
M2UxYzMzMzM0NDM1ZjdjNWZkZGM4MmRkYzAxNTc0NTRkMmJlYTg=
|
data/lib/patriot/command.rb
CHANGED
@@ -19,8 +19,8 @@ module Patriot
|
|
19
19
|
EXEC_HOST_ATTR = "exec_host"
|
20
20
|
# attribute name for start time constraint
|
21
21
|
START_DATETIME_ATTR = "start_datetime"
|
22
|
-
# attribute name for
|
23
|
-
|
22
|
+
# attribute name for retry configration
|
23
|
+
POST_PROCESSORS_ATTR = "post_processors"
|
24
24
|
|
25
25
|
# a list of comman attributes
|
26
26
|
COMMON_ATTRIBUTES = [
|
@@ -31,7 +31,7 @@ module Patriot
|
|
31
31
|
EXEC_NODE_ATTR,
|
32
32
|
EXEC_HOST_ATTR,
|
33
33
|
START_DATETIME_ATTR,
|
34
|
-
|
34
|
+
POST_PROCESSORS_ATTR
|
35
35
|
]
|
36
36
|
|
37
37
|
# exit code of a command
|
@@ -40,8 +40,6 @@ module Patriot
|
|
40
40
|
SUCCEEDED = 0
|
41
41
|
# failed
|
42
42
|
FAILED = 1
|
43
|
-
# failed but skipped (marked skip_on_fail)
|
44
|
-
FAILURE_SKIPPED = 2
|
45
43
|
# skip (e.g., updated elsewhere)
|
46
44
|
SKIPPED = -1
|
47
45
|
|
@@ -50,19 +48,30 @@ module Patriot
|
|
50
48
|
def name_of(exit_code)
|
51
49
|
exit_code = exit_code.to_i
|
52
50
|
return case exit_code
|
53
|
-
when
|
54
|
-
when
|
55
|
-
|
56
|
-
when 4 then "FAILED" # for backward compatibility
|
57
|
-
else raise "unknown exit_code #{exit_code}"
|
51
|
+
when SUCCEEDED then "SUCCEEDED"
|
52
|
+
when FAILED then "FAILED"
|
53
|
+
else exit_code.to_s # not nil for backward compatibility
|
58
54
|
end
|
59
55
|
end
|
60
56
|
module_function :name_of
|
57
|
+
|
58
|
+
# @param code_name [Patriot::Command::ExitCode]
|
59
|
+
# @return [Fixnum] exit code of the code name
|
60
|
+
def value_of(code_name)
|
61
|
+
return code_name if code_name.is_a?(Fixnum)
|
62
|
+
return case code_name
|
63
|
+
when /SUCCEEDED/i then SUCCEEDED
|
64
|
+
when /FAILED/i then FAILED
|
65
|
+
else raise "unknown exit code name: #{code_name}"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
module_function :value_of
|
61
69
|
end
|
62
70
|
|
63
71
|
require 'patriot/command/parser'
|
64
72
|
require 'patriot/command/command_macro'
|
65
73
|
require 'patriot/command/base'
|
74
|
+
require 'patriot/command/post_processor'
|
66
75
|
require 'patriot/command/command_group'
|
67
76
|
require 'patriot/command/composite'
|
68
77
|
require 'patriot/command/sh_command'
|
data/lib/patriot/command/base.rb
CHANGED
@@ -13,10 +13,17 @@ module Patriot
|
|
13
13
|
include Patriot::Command::CommandMacro
|
14
14
|
end
|
15
15
|
|
16
|
-
attr_accessor :parser, :test_mode, :target_datetime
|
16
|
+
attr_accessor :config, :parser, :test_mode, :target_datetime, :post_processors
|
17
|
+
attr_writer :start_datetime
|
17
18
|
|
18
19
|
# comman attributes handled distinctively (only effective in top level commands)
|
19
|
-
volatile_attr :requisites,
|
20
|
+
volatile_attr :requisites,
|
21
|
+
:products,
|
22
|
+
:priority,
|
23
|
+
:start_after,
|
24
|
+
:exec_date,
|
25
|
+
:exec_node,
|
26
|
+
:exec_host
|
20
27
|
|
21
28
|
# @param config [Patriot::Util::Config::Base] configuration for this command
|
22
29
|
def initialize(config)
|
@@ -82,11 +89,6 @@ module Patriot
|
|
82
89
|
param 'state' => Patriot::JobStore::JobState::SUSPEND
|
83
90
|
end
|
84
91
|
|
85
|
-
# mark this job to skip in case of failures
|
86
|
-
def skip_on_fail?
|
87
|
-
return @skip_on_fail == 'true' || @skip_on_fail == true
|
88
|
-
end
|
89
|
-
|
90
92
|
# @return [String] the target month in '%Y-%m'
|
91
93
|
def _month_
|
92
94
|
return @target_datetime.strftime("%Y-%m")
|
@@ -109,14 +111,14 @@ module Patriot
|
|
109
111
|
|
110
112
|
# start datetime of this command.
|
111
113
|
# This command should be executed after the return value of this method
|
112
|
-
# @return [
|
114
|
+
# @return [Time]
|
113
115
|
def start_date_time
|
114
116
|
return nil if @exec_date.nil? && @start_after.nil?
|
115
117
|
# set tomorrow as default
|
116
118
|
date = (@exec_date || date_add(_date_, 1)).split("-").map(&:to_i)
|
117
119
|
# set midnight as default
|
118
120
|
time = (@start_after || "00:00:00").split(":").map(&:to_i)
|
119
|
-
return
|
121
|
+
return Time.new(date[0], date[1], date[2], time[0], time[1], time[2])
|
120
122
|
end
|
121
123
|
|
122
124
|
# update parameters with a given hash.
|
@@ -187,6 +189,13 @@ module Patriot
|
|
187
189
|
raise "sub command is not supported"
|
188
190
|
end
|
189
191
|
|
192
|
+
# add a post processor
|
193
|
+
# @param [Patriot::Command::PostProcessor::Base] a post processor for this job
|
194
|
+
def add_post_processor(post_processor)
|
195
|
+
@post_processors ||= []
|
196
|
+
@post_processors << post_processor
|
197
|
+
end
|
198
|
+
|
190
199
|
# @return description of this command
|
191
200
|
def description
|
192
201
|
self.job_id
|
@@ -18,7 +18,7 @@ module Patriot
|
|
18
18
|
end
|
19
19
|
|
20
20
|
# parse DSL by processing the DSL description as block
|
21
|
-
# @param datetime [
|
21
|
+
# @param datetime [Time] the datetime for which the job works
|
22
22
|
# @return a list of command defined in the DSL description
|
23
23
|
def parse(datetime, blk)
|
24
24
|
self.target_datetime = datetime
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# the root name space for this scheduler
|
2
|
+
module Patriot
|
3
|
+
# a name space for commands
|
4
|
+
module Command
|
5
|
+
module PostProcessor
|
6
|
+
POST_PROCESSOR_CLASS_KEY = "POST_PROCESSOR_CLASS"
|
7
|
+
require 'patriot/command/post_processor/base'
|
8
|
+
require 'patriot/command/post_processor/skip_on_fail'
|
9
|
+
require 'patriot/command/post_processor/retrial'
|
10
|
+
require 'patriot/command/post_processor/mail_notification'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Patriot
|
2
|
+
module Command
|
3
|
+
module PostProcessor
|
4
|
+
|
5
|
+
# The base class of every post processor
|
6
|
+
class Base
|
7
|
+
|
8
|
+
# declare DSL method name for adding a post processor
|
9
|
+
# @param mth_name [String] the DSL method name
|
10
|
+
# @param parent_cls [Class<Patriot::Command::Base>] parent command in which the post porcessor is available
|
11
|
+
# @param processor_cls [Class<Patriot::Command::PostProcessor::Base] the class of the post processor
|
12
|
+
def self.declare_post_processor_name(mth_name, parent_cls=Patriot::Command::Base, processor_cls=self)
|
13
|
+
parent_cls.class_eval do
|
14
|
+
define_method(mth_name) do |processor_props = {}|
|
15
|
+
pp = processor_cls.new(processor_props)
|
16
|
+
add_post_processor(pp)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
attr_accessor :props
|
22
|
+
|
23
|
+
# @param props [Hash] properties of this post processor
|
24
|
+
def initialize(props = {})
|
25
|
+
validate_props(props)
|
26
|
+
@props = props
|
27
|
+
end
|
28
|
+
|
29
|
+
def validate_props(props)
|
30
|
+
end
|
31
|
+
|
32
|
+
def process(cmd, worker, job_ticket)
|
33
|
+
case job_ticket.exit_code
|
34
|
+
when Patriot::Command::ExitCode::SUCCEEDED then process_success(cmd, worker, job_ticket)
|
35
|
+
when Patriot::Command::ExitCode::FAILED then process_failure(cmd, worker, job_ticket)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def process_success(cmd, worker, job_ticket)
|
40
|
+
end
|
41
|
+
|
42
|
+
def process_failure(cmd, worker, job_ticket)
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'mail'
|
2
|
+
module Patriot
|
3
|
+
module Command
|
4
|
+
module PostProcessor
|
5
|
+
class MailNotification < Patriot::Command::PostProcessor::Base
|
6
|
+
|
7
|
+
TO_PROP_KEY = 'to'
|
8
|
+
ON_PROP_KEY = 'on'
|
9
|
+
|
10
|
+
declare_post_processor_name :mail_notification
|
11
|
+
|
12
|
+
def validate_props(props)
|
13
|
+
raise "#{TO_PROP_KEY} is not specified" unless props.has_key?(TO_PROP_KEY)
|
14
|
+
raise "#{ON_PROP_KEY} is not specified" unless props.has_key?(ON_PROP_KEY)
|
15
|
+
end
|
16
|
+
|
17
|
+
def process(cmd, worker, job_ticket)
|
18
|
+
on = @props[ON_PROP_KEY]
|
19
|
+
on = [on] unless on.is_a?(Array)
|
20
|
+
on = on.map{|o| Patriot::Command::ExitCode.value_of(o)}
|
21
|
+
exit_code = job_ticket.exit_code
|
22
|
+
return unless on.include?(exit_code)
|
23
|
+
case exit_code
|
24
|
+
when Patriot::Command::ExitCode::SUCCEEDED then process_success(cmd, worker, job_ticket)
|
25
|
+
when Patriot::Command::ExitCode::FAILED then process_failure(cmd, worker, job_ticket)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def process_success(cmd, worker, job_ticket)
|
30
|
+
from = worker.config.get(Patriot::Util::Config::ADMIN_USER_KEY)
|
31
|
+
to = @props[TO_PROP_KEY]
|
32
|
+
subject = "#{job_ticket.job_id} has been successfully finished"
|
33
|
+
body = "#{job_ticket.job_id} has been successfully finished \n\n --- \n #{job_ticket.description}"
|
34
|
+
deliver(from, to, subject, body)
|
35
|
+
end
|
36
|
+
|
37
|
+
def process_failure(cmd, worker, job_ticket)
|
38
|
+
from = worker.config.get(Patriot::Util::Config::ADMIN_USER_KEY)
|
39
|
+
to = @props[TO_PROP_KEY]
|
40
|
+
subject = "#{job_ticket.job_id} has been failed"
|
41
|
+
body = "#{job_ticket.job_id} has been failed \n\n --- \n #{job_ticket.description}"
|
42
|
+
deliver(from, to, subject, body)
|
43
|
+
end
|
44
|
+
|
45
|
+
def deliver(from_addr, to_addr, msg_subj, msg_body)
|
46
|
+
Mail.deliver do
|
47
|
+
from from_addr
|
48
|
+
to to_addr
|
49
|
+
subject msg_subj
|
50
|
+
body msg_body
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Patriot
|
2
|
+
module Command
|
3
|
+
module PostProcessor
|
4
|
+
class Retrial < Patriot::Command::PostProcessor::Base
|
5
|
+
|
6
|
+
COUNT_PROP_KEY = 'count'
|
7
|
+
INTERVAL_PROP_KEY = 'interval'
|
8
|
+
|
9
|
+
declare_post_processor_name :retrial
|
10
|
+
|
11
|
+
def validate_props(props)
|
12
|
+
raise "#{COUNT_PROP_KEY} is not specified" unless props.has_key?(COUNT_PROP_KEY)
|
13
|
+
raise "#{INTERVAL_PROP_KEY} is not specified" unless props.has_key?(INTERVAL_PROP_KEY)
|
14
|
+
end
|
15
|
+
|
16
|
+
def process_failure(cmd, worker, job_ticket)
|
17
|
+
found = false
|
18
|
+
cmd.post_processors.each do |pp|
|
19
|
+
next unless pp.is_a?(Patriot::Command::PostProcessor::Retrial)
|
20
|
+
raise "multiple retry processors in #{cmd.job_id}" if found
|
21
|
+
found = true
|
22
|
+
# count first attempt in
|
23
|
+
pp.props[COUNT_PROP_KEY] = pp.props[COUNT_PROP_KEY] - 1
|
24
|
+
return if pp.props[COUNT_PROP_KEY] == 0
|
25
|
+
cmd.start_datetime = Time.now + pp.props[INTERVAL_PROP_KEY]
|
26
|
+
end
|
27
|
+
job = cmd.to_job
|
28
|
+
job[Patriot::Command::STATE_ATTR] = Patriot::JobStore::JobState::WAIT
|
29
|
+
worker.job_store.register(Time.now.to_i, [job])
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Patriot
|
2
|
+
module Command
|
3
|
+
module PostProcessor
|
4
|
+
|
5
|
+
class SkipOnFail < Patriot::Command::PostProcessor::Base
|
6
|
+
|
7
|
+
declare_post_processor_name :skip_on_fail
|
8
|
+
|
9
|
+
def process_failure(cmd, worker, job_ticket)
|
10
|
+
worker.job_store.set_state(Time.now.to_i, [cmd.job_id], Patriot::JobStore::JobState::SUCCEEDED)
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
|
data/lib/patriot/job_store.rb
CHANGED
@@ -40,9 +40,8 @@ module Patriot
|
|
40
40
|
# mapping from exit code to job state
|
41
41
|
# @see Patriot::Command::ExitCode
|
42
42
|
EXIT_CODE_TO_STATE = {
|
43
|
-
Patriot::Command::ExitCode::SUCCEEDED
|
44
|
-
Patriot::Command::ExitCode::
|
45
|
-
Patriot::Command::ExitCode::FAILED => Patriot::JobStore::JobState::FAILED
|
43
|
+
Patriot::Command::ExitCode::SUCCEEDED => Patriot::JobStore::JobState::SUCCEEDED,
|
44
|
+
Patriot::Command::ExitCode::FAILED => Patriot::JobStore::JobState::FAILED
|
46
45
|
}
|
47
46
|
|
48
47
|
# a prefix for configuration key
|
@@ -43,7 +43,7 @@ module Patriot
|
|
43
43
|
def read_command(command)
|
44
44
|
Patriot::Command::COMMON_ATTRIBUTES.each do |attr|
|
45
45
|
value = command.instance_variable_get("@#{attr}".to_sym)
|
46
|
-
self[attr] = value unless value.nil?
|
46
|
+
self[attr] = _to_stdobj(value) unless value.nil?
|
47
47
|
end
|
48
48
|
_to_stdobj(command).each{|k,v| self[k] = v}
|
49
49
|
end
|
@@ -60,6 +60,13 @@ module Patriot
|
|
60
60
|
hash[attr.to_s] = _to_stdobj(value) unless value.nil?
|
61
61
|
end
|
62
62
|
return hash
|
63
|
+
elsif obj.is_a?(Patriot::Command::PostProcessor::Base)
|
64
|
+
hash = {}
|
65
|
+
hash[Patriot::Command::PostProcessor::POST_PROCESSOR_CLASS_KEY] = obj.class.to_s.gsub(/::/, '.')
|
66
|
+
obj.props.each do |k,v|
|
67
|
+
hash[k.to_s] = _to_stdobj(v) unless v.nil?
|
68
|
+
end
|
69
|
+
return hash
|
63
70
|
elsif obj.is_a?(Hash)
|
64
71
|
hash = {}
|
65
72
|
obj.each{|k,v| hash[k.to_s] = _to_stdobj(v)}
|
@@ -94,6 +101,10 @@ module Patriot
|
|
94
101
|
cmd.instance_variable_set("@#{k}".to_sym, _from_stdobj(v, config))
|
95
102
|
end
|
96
103
|
return cmd
|
104
|
+
elsif obj.has_key?(Patriot::Command::PostProcessor::POST_PROCESSOR_CLASS_KEY)
|
105
|
+
cmd_cls = obj.delete(Patriot::Command::PostProcessor::POST_PROCESSOR_CLASS_KEY)
|
106
|
+
cmd_cls = cmd_cls.split('.').inject(Object){|c,name| c.const_get(name)}
|
107
|
+
return cmd_cls.new(obj)
|
97
108
|
else
|
98
109
|
hash = {}
|
99
110
|
obj.each{|k,v| hash[k] = _from_stdobj(v, config)}
|
@@ -48,7 +48,9 @@ module Patriot
|
|
48
48
|
# @return an array of commands
|
49
49
|
def parse(date, files, options = {}, &blk)
|
50
50
|
return if files.empty?
|
51
|
-
|
51
|
+
ds = date.split('-')
|
52
|
+
raise "illegal format of date #{date}" unless ds.size == 3
|
53
|
+
datetime = Time.new(ds[0], ds[1], ds[2])
|
52
54
|
# for backward compatibility to be removed
|
53
55
|
$dt = date
|
54
56
|
$month = date.split('-').values_at(0,1).join('-')
|
data/lib/patriot/util/config.rb
CHANGED
@@ -21,14 +21,16 @@ module Patriot
|
|
21
21
|
# the list of minutes
|
22
22
|
MINUTES = 0.upto(59).to_a
|
23
23
|
|
24
|
+
DAY_IN_SECOND = 60 * 60 * 24
|
25
|
+
|
24
26
|
# expand a given date to the array of time which should be executed in case of a given cron field
|
25
|
-
# @param date [
|
27
|
+
# @param date [Time] target datetime
|
26
28
|
# @param cron_field [String] interval in cron format
|
27
|
-
# @return [Array<
|
29
|
+
# @return [Array<Time>] a list of datetime which match the cron format
|
28
30
|
def expand_on_date(date, cron_field = nil)
|
29
31
|
cron_field = DEFAULT_CRON_FIELD if cron_field.nil? || cron_field.empty?
|
30
32
|
if cron_field == END_OF_EVERY_MONTH
|
31
|
-
return date.
|
33
|
+
return (date + DAY_IN_SECOND).day == 1 ? [date] : []
|
32
34
|
end
|
33
35
|
field_splits = cron_field.split
|
34
36
|
raise "illegal cron field format #{cron_field}" unless field_splits.size == 5
|
@@ -36,13 +38,13 @@ module Patriot
|
|
36
38
|
return [] unless is_target_day?(date, day, month, week)
|
37
39
|
return target_hours(hour).map do |h|
|
38
40
|
target_minutes(minute).map do |m|
|
39
|
-
|
41
|
+
Time.new(date.year, date.month, date.day, h, m, 0)
|
40
42
|
end
|
41
43
|
end.flatten
|
42
44
|
end
|
43
45
|
|
44
46
|
# check a given date is a target or not
|
45
|
-
# @param date [
|
47
|
+
# @param date [Time] a datetime to be checked
|
46
48
|
# @param day [String] day field in cron format
|
47
49
|
# @param month [String] month field in cron format
|
48
50
|
# @param week [String] week field in cron format
|
@@ -35,7 +35,7 @@ module Patriot
|
|
35
35
|
min = min%60
|
36
36
|
hour = hour%24
|
37
37
|
|
38
|
-
new_dt = DateTime.new(year, month, day, hour, min,sec)
|
38
|
+
new_dt = DateTime.new(year, month, day, hour, min, sec)
|
39
39
|
new_dt = new_dt >> diff[:month]
|
40
40
|
new_dt = new_dt + diff[:day]
|
41
41
|
return new_dt.strftime(fmt)
|
data/lib/patriot/worker/base.rb
CHANGED
@@ -12,7 +12,7 @@ module Patriot
|
|
12
12
|
include Patriot::Util::Retry
|
13
13
|
include Patriot::JobStore::Factory
|
14
14
|
|
15
|
-
attr_accessor :host, :status, :cycle, :job_store
|
15
|
+
attr_accessor :host, :status, :cycle, :job_store, :config
|
16
16
|
|
17
17
|
# @param config [Patriot::Util::Config::Base]
|
18
18
|
def initialize(config)
|
@@ -47,7 +47,7 @@ module Patriot
|
|
47
47
|
@logger.info " executing job: #{job_ticket.job_id}"
|
48
48
|
command = response[:command]
|
49
49
|
job_ticket.execution_id = response[:execution_id]
|
50
|
-
job_ticket.exit_code =
|
50
|
+
job_ticket.exit_code = Patriot::Command::ExitCode::FAILED
|
51
51
|
begin
|
52
52
|
command.execute
|
53
53
|
job_ticket.exit_code = Patriot::Command::ExitCode::SUCCEEDED
|
@@ -62,6 +62,17 @@ module Patriot
|
|
62
62
|
rescue Exception => job_store_error
|
63
63
|
@logger.error job_store_error
|
64
64
|
end
|
65
|
+
unless command.post_processors.nil?
|
66
|
+
command.post_processors.each do |pp|
|
67
|
+
begin
|
68
|
+
@logger.info "executing post process by #{pp}"
|
69
|
+
pp.process(command, self, job_ticket)
|
70
|
+
rescue Exception => post_process_error
|
71
|
+
@logger.error "post process by #{pp} failed"
|
72
|
+
@logger.error post_process_error
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
65
76
|
end
|
66
77
|
return job_ticket.exit_code
|
67
78
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: patriot-workflow-scheduler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Teruyoshi Zenmyo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - ~>
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '1.4'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: mail
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ~>
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '2.6'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ~>
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '2.6'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: tilt
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -153,6 +167,11 @@ files:
|
|
153
167
|
- lib/patriot/command/command_macro.rb
|
154
168
|
- lib/patriot/command/composite.rb
|
155
169
|
- lib/patriot/command/parser.rb
|
170
|
+
- lib/patriot/command/post_processor.rb
|
171
|
+
- lib/patriot/command/post_processor/base.rb
|
172
|
+
- lib/patriot/command/post_processor/mail_notification.rb
|
173
|
+
- lib/patriot/command/post_processor/retrial.rb
|
174
|
+
- lib/patriot/command/post_processor/skip_on_fail.rb
|
156
175
|
- lib/patriot/command/sh_command.rb
|
157
176
|
- lib/patriot/controller.rb
|
158
177
|
- lib/patriot/controller/package_controller.rb
|