herdst_worker 0.2.16 → 0.2.18
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/herdst_worker/application/facade.rb +14 -4
- data/lib/herdst_worker/queue/processor.rb +18 -11
- data/lib/herdst_worker/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1cb8f2fe78959dcc72ddb5262d5f775f7e2c8894e4cea3079df5574bc9afa469
|
|
4
|
+
data.tar.gz: 26a30f925cd508910027e86449fc2ed0832dd64232c94f1992b0743a6f108046
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 72a91bfab0fd4e3c19a6c98eb5c1cbca69c0d07950165145ec15d9c877593f8a497d7c21b931d4ad356141edafe0908556612da24e574352289d38f6fcc9449c
|
|
7
|
+
data.tar.gz: 013a1ef632e3f4fb751399e86fb2004bef44bd84d3fcc17a22a11919f4ba986c2428ee8c48ed38e5c4de7d9fd427de9bc7cd29276e2c487fd69aa02469c3360b
|
|
@@ -69,13 +69,23 @@ module HerdstWorker
|
|
|
69
69
|
|
|
70
70
|
|
|
71
71
|
def stop(exit_code = 0)
|
|
72
|
-
|
|
73
|
-
self.logger.queue.warn "Application exiting (#{exit_code})"
|
|
72
|
+
self.logger.warn "Application exiting (#{exit_code})"
|
|
74
73
|
|
|
75
|
-
|
|
76
|
-
end
|
|
74
|
+
Kernel.exit(exit_code)
|
|
77
75
|
end
|
|
78
76
|
|
|
77
|
+
|
|
78
|
+
def force_stop(delay = 1)
|
|
79
|
+
self.logger.warn "Application force stopping in #{delay} seconds."
|
|
80
|
+
process_id = "#{$$}"
|
|
81
|
+
|
|
82
|
+
Concurrent::ScheduledTask.execute(delay) do
|
|
83
|
+
self.logger.warn "Application force stopping."
|
|
84
|
+
|
|
85
|
+
system("kill -9 #{process_id}")
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
79
89
|
|
|
80
90
|
def config_for(name)
|
|
81
91
|
self.config.config_for(name)
|
|
@@ -9,7 +9,7 @@ module HerdstWorker
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
attr_accessor :app, :enabled, :queue_url, :queue_wait_time, :poller
|
|
12
|
-
attr_accessor :start_time, :restart_time, :run_time
|
|
12
|
+
attr_accessor :start_time, :restart_time, :run_time, :force_stop_delay
|
|
13
13
|
attr_accessor :processor_status, :job_count, :max_jobs
|
|
14
14
|
attr_accessor :attempt_threshold, :visibility_timeout, :ignored_notifications
|
|
15
15
|
|
|
@@ -30,6 +30,7 @@ module HerdstWorker
|
|
|
30
30
|
|
|
31
31
|
# Set the start time
|
|
32
32
|
self.run_time = (3600 * 4) + (rand * 600).floor # Four hours + bit more (< 10 minutes)
|
|
33
|
+
self.force_stop_delay = 600 # 10 minutes
|
|
33
34
|
self.reset_time
|
|
34
35
|
|
|
35
36
|
# Start the processor as working
|
|
@@ -48,6 +49,10 @@ module HerdstWorker
|
|
|
48
49
|
self.poller.poll(:wait_time_seconds => self.queue_wait_time, :skip_delete => false) do |msg|
|
|
49
50
|
process_message(msg)
|
|
50
51
|
end
|
|
52
|
+
|
|
53
|
+
if self.processor_status == "stopped"
|
|
54
|
+
self.app.stop(0)
|
|
55
|
+
end
|
|
51
56
|
else
|
|
52
57
|
raise "Cannot start a queue which is not enabled"
|
|
53
58
|
end
|
|
@@ -117,32 +122,34 @@ module HerdstWorker
|
|
|
117
122
|
current_time = Time.now.utc.to_i
|
|
118
123
|
if (self.processor_status == "working") && (current_time >= self.restart_time)
|
|
119
124
|
runtime = current_time - self.start_time
|
|
120
|
-
self.app.logger.queue.warn "
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
+
self.app.logger.queue.warn "Preparing to stop after #{runtime} seconds of work"
|
|
126
|
+
self.app.force_stop(self.force_stop_delay)
|
|
127
|
+
|
|
128
|
+
set_status "stopping"
|
|
129
|
+
|
|
130
|
+
# On finishing wait for jobs to complete and then set status to idle
|
|
125
131
|
elsif self.processor_status == "finishing"
|
|
126
132
|
if self.job_count == 0
|
|
127
133
|
self.app.logger.queue.warn "Setting processor status to idle"
|
|
128
134
|
set_status "idle"
|
|
129
135
|
end
|
|
130
136
|
|
|
137
|
+
end
|
|
138
|
+
|
|
131
139
|
# On stopping wait for jobs to complete and then set status
|
|
132
140
|
# to stopped. Once stopped the polling will terminate.
|
|
133
|
-
|
|
141
|
+
if self.processor_status == "stopping"
|
|
134
142
|
if self.job_count == 0
|
|
135
143
|
self.app.logger.queue.warn "Setting processor status to stopped"
|
|
136
144
|
set_status "stopped"
|
|
137
145
|
end
|
|
138
|
-
|
|
139
146
|
end
|
|
140
147
|
|
|
148
|
+
# Once stopped exit the application
|
|
141
149
|
if self.processor_status == "stopped"
|
|
142
150
|
self.app.logger.queue.warn "Stopping polling, Service requested to stop"
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
raise :stop_polling
|
|
151
|
+
|
|
152
|
+
throw :stop_polling
|
|
146
153
|
end
|
|
147
154
|
end
|
|
148
155
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: herdst_worker
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.18
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Herd.St
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-01-
|
|
11
|
+
date: 2026-01-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|