task-orchestrator 0.0.13 → 0.0.14

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.
@@ -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', 'Do not use state file if it exists' ) { options.reset = true }
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
 
@@ -65,7 +65,18 @@ module Orchestrator
65
65
  end
66
66
  end
67
67
 
68
- @state = (File.exist?(@options.statefile) && !@options.reset) ? YAML.load_file(@options.statefile) : @settings['orchestrator'][@options.name]
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
 
@@ -1,3 +1,3 @@
1
1
  module Orchestrator
2
- VERSION ||= '0.0.13'
2
+ VERSION ||= '0.0.14'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: task-orchestrator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: