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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 450826afb7188d0ae286c676c371df22057f6f3db4e5a8be220674292d5f94b9
4
- data.tar.gz: 16f8a3ef64cb3659e10a5be61f02e0948591377b7b1f1549bb19fef7d16abab4
3
+ metadata.gz: 943695a0b61808c8db91070a49ea4fdedc5616a4769f6522eccd0c7bca2a9541
4
+ data.tar.gz: d8c1d987a8c60bc943c2c156c4642a296e622ff71ab3e43412e35edefcdc9e37
5
5
  SHA512:
6
- metadata.gz: 397b4c6aaae865d7fc8de5faf50b775ed0762afbaebc6aaf9d80c51fb7e1bacbf33a0e653e6932d14fdc43f0f9142efa873ac2d22b3f6910ab2c28114bdbcf27
7
- data.tar.gz: 1f6592fb6d417d85b3c68c608fb34775a771614674f98f2ddcd50fca25e7b7c5ab9d741bb012e53f70e1ec8abc4a256fc7ac4b8a46cf2794054987d405586ee7
6
+ metadata.gz: 2d8b349c120bb241a147509b489843fa7c8a7928660696471c5dbfcccf2a45eaff1e82d6c5630a81a659106a31b5344666c8d2e1e530b0b39832b6fe8c9949b8
7
+ data.tar.gz: 4d97b9f059722033d67c09049d9c5d66690123b60fd4ca827c3a8301b7ddd32388352b1af49802fd92870d1ac022f9ad9a96579fe182c7c905dfb7f5d023786c
@@ -7,6 +7,10 @@ require_relative 'cli/prompt_change_handler'
7
7
 
8
8
  module AiSentinel
9
9
  class CLI < Thor
10
+ def self.exit_on_failure?
11
+ true
12
+ end
13
+
10
14
  include Helpers
11
15
  include ContextDisplay
12
16
  include PromptChangeHandler
@@ -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
- AiSentinel.logger.info("AiSentinel started in background (#{registry.size} workflow(s))")
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AiSentinel
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
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.0
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