task-orchestrator 0.0.13 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/orchestrator/cli.rb +15 -2
- data/lib/orchestrator/task.rb +12 -1
- data/lib/orchestrator/version.rb +1 -1
- metadata +1 -1
data/lib/orchestrator/cli.rb
CHANGED
@@ -19,20 +19,23 @@ module Orchestrator
|
|
19
19
|
options.args.instance_variable_set(:@config,config)
|
20
20
|
end
|
21
21
|
|
22
|
-
options.statefile = nil
|
23
22
|
options.name = nil
|
24
23
|
parser.on( '--name NAME', 'Name of the cron job to run' ) do |name|
|
25
24
|
options.name = name
|
26
25
|
options.args.instance_variable_set(:@name,name)
|
27
26
|
end
|
28
27
|
|
28
|
+
options.statefile = nil
|
29
29
|
parser.on( '--statefile PATH', String, 'Path to state file yaml' ) do |statefile|
|
30
30
|
options.statefile = statefile
|
31
31
|
options.args.instance_variable_set(:@statefile,statefile)
|
32
32
|
end
|
33
33
|
|
34
34
|
options.reset = false
|
35
|
-
parser.on( '--reset', '
|
35
|
+
parser.on( '--reset', 'Delete state file if it exists' ) { options.reset = true }
|
36
|
+
|
37
|
+
options.resume = false
|
38
|
+
parser.on( '--resume', 'Resume from statefile if it exists' ) { options.resume = true }
|
36
39
|
|
37
40
|
options.kill = false
|
38
41
|
parser.on( '--kill', 'Kill running task based on statefile pid then lock can not be acquired' ) { options.kill = true }
|
@@ -65,6 +68,16 @@ module Orchestrator
|
|
65
68
|
exit 1
|
66
69
|
end
|
67
70
|
|
71
|
+
if options.reset && options.resume
|
72
|
+
Formatador.display_line("[red]ERROR[/]: --resume or --reset options are mutualy exclusive")
|
73
|
+
exit 1
|
74
|
+
end
|
75
|
+
|
76
|
+
if options.wait && options.kill
|
77
|
+
Formatador.display_line("[red]ERROR[/]: --wait or --kill options are mutualy exclusive")
|
78
|
+
exit 1
|
79
|
+
end
|
80
|
+
|
68
81
|
options
|
69
82
|
end
|
70
83
|
|
data/lib/orchestrator/task.rb
CHANGED
@@ -65,7 +65,18 @@ module Orchestrator
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
-
|
68
|
+
if File.exist?(@options.statefile)
|
69
|
+
if @options.reset
|
70
|
+
@state = @settings['orchestrator'][@options.name]
|
71
|
+
elsif @options.resume
|
72
|
+
@state = YAML.load_file(@options.statefile)
|
73
|
+
else
|
74
|
+
Formatador.display_line("[red]ERROR[/]: statefile #{@options.statefile} already exists, use --resume or --reset")
|
75
|
+
exit 1
|
76
|
+
end
|
77
|
+
else
|
78
|
+
@state = @settings['orchestrator'][@options.name]
|
79
|
+
end
|
69
80
|
|
70
81
|
@state['pid'] = Process.pid
|
71
82
|
|
data/lib/orchestrator/version.rb
CHANGED