ai_sentinel 0.1.0 → 0.1.1
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 +4 -4
- data/lib/ai_sentinel/cli.rb +4 -0
- data/lib/ai_sentinel/scheduler.rb +25 -8
- data/lib/ai_sentinel/version.rb +1 -1
- metadata +15 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 943695a0b61808c8db91070a49ea4fdedc5616a4769f6522eccd0c7bca2a9541
|
|
4
|
+
data.tar.gz: d8c1d987a8c60bc943c2c156c4642a296e622ff71ab3e43412e35edefcdc9e37
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2d8b349c120bb241a147509b489843fa7c8a7928660696471c5dbfcccf2a45eaff1e82d6c5630a81a659106a31b5344666c8d2e1e530b0b39832b6fe8c9949b8
|
|
7
|
+
data.tar.gz: 4d97b9f059722033d67c09049d9c5d66690123b60fd4ca827c3a8301b7ddd32388352b1af49802fd92870d1ac022f9ad9a96579fe182c7c905dfb7f5d023786c
|
data/lib/ai_sentinel/cli.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'fileutils'
|
|
3
4
|
require 'rufus-scheduler'
|
|
4
5
|
|
|
5
6
|
module AiSentinel
|
|
@@ -9,21 +10,25 @@ module AiSentinel
|
|
|
9
10
|
def initialize(registry, configuration)
|
|
10
11
|
@registry = registry
|
|
11
12
|
@configuration = configuration
|
|
12
|
-
@rufus = Rufus::Scheduler.new
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def start(daemonize: false)
|
|
16
|
-
register_workflows
|
|
17
|
-
|
|
18
16
|
if daemonize
|
|
19
|
-
|
|
17
|
+
Process.daemon(true, true)
|
|
18
|
+
write_pid_file
|
|
19
|
+
AiSentinel.logger.info("AiSentinel started in background (PID #{Process.pid}, #{registry.size} workflow(s))")
|
|
20
20
|
else
|
|
21
21
|
AiSentinel.logger.info("AiSentinel started (#{registry.size} workflow(s)). Press Ctrl+C to stop.")
|
|
22
|
-
trap('INT') { Thread.new { stop } }
|
|
23
|
-
trap('TERM') { Thread.new { stop } }
|
|
24
|
-
@rufus.join
|
|
25
|
-
AiSentinel.logger.info('AiSentinel stopped')
|
|
26
22
|
end
|
|
23
|
+
|
|
24
|
+
@rufus = Rufus::Scheduler.new
|
|
25
|
+
register_workflows
|
|
26
|
+
|
|
27
|
+
trap('INT') { Thread.new { stop } }
|
|
28
|
+
trap('TERM') { Thread.new { stop } }
|
|
29
|
+
@rufus.join
|
|
30
|
+
cleanup_pid_file
|
|
31
|
+
AiSentinel.logger.info('AiSentinel stopped')
|
|
27
32
|
end
|
|
28
33
|
|
|
29
34
|
def stop
|
|
@@ -38,8 +43,20 @@ module AiSentinel
|
|
|
38
43
|
runner.execute
|
|
39
44
|
end
|
|
40
45
|
|
|
46
|
+
def pid_file
|
|
47
|
+
@pid_file ||= File.join(Dir.pwd, 'ai_sentinel.pid')
|
|
48
|
+
end
|
|
49
|
+
|
|
41
50
|
private
|
|
42
51
|
|
|
52
|
+
def write_pid_file
|
|
53
|
+
File.write(pid_file, Process.pid.to_s)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def cleanup_pid_file
|
|
57
|
+
FileUtils.rm_f(pid_file)
|
|
58
|
+
end
|
|
59
|
+
|
|
43
60
|
def register_workflows
|
|
44
61
|
registry.each do |name, workflow|
|
|
45
62
|
@rufus.cron(workflow.schedule_expression) do
|
data/lib/ai_sentinel/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ai_sentinel
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mario Celi
|
|
@@ -93,6 +93,20 @@ dependencies:
|
|
|
93
93
|
- - "~>"
|
|
94
94
|
- !ruby/object:Gem::Version
|
|
95
95
|
version: '1.0'
|
|
96
|
+
- !ruby/object:Gem::Dependency
|
|
97
|
+
name: tzinfo-data
|
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
|
99
|
+
requirements:
|
|
100
|
+
- - "~>"
|
|
101
|
+
- !ruby/object:Gem::Version
|
|
102
|
+
version: '1.0'
|
|
103
|
+
type: :runtime
|
|
104
|
+
prerelease: false
|
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
106
|
+
requirements:
|
|
107
|
+
- - "~>"
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
version: '1.0'
|
|
96
110
|
- !ruby/object:Gem::Dependency
|
|
97
111
|
name: zeitwerk
|
|
98
112
|
requirement: !ruby/object:Gem::Requirement
|