diffbroker 0.12.0 → 0.12.2
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/diffbroker/daemon.rb +13 -3
- data/lib/diffbroker/task_runner.rb +12 -0
- data/lib/diffbroker/version.rb +1 -1
- data/plugin/.claude-plugin/plugin.json +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 843632a85c52d68a7b94d6a1f7dd1229e7353961a5611a7ed9c1cb05d7f11542
|
|
4
|
+
data.tar.gz: 7a0c380a109114c7feeb13b203fc45a05e95f3da9773288e0b77e52d6df12a58
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1d432acb33edef5d5f4d7699445a4e1a53f119499ecc94ea70e10001eb7c894358efe5d74984495d660230924510f89ff9656e9252afe11e73bb96d11b4d54db
|
|
7
|
+
data.tar.gz: 60b4a66bd37677fcf6f39ea798d7b7c0fee21cd04167cd102d7958af51cfa1f2f6ccbba05070825eba84239c2209da07c3c91ef6870d4373be4d46d6e906d33a
|
data/lib/diffbroker/daemon.rb
CHANGED
|
@@ -149,6 +149,7 @@ module Diffbroker
|
|
|
149
149
|
end
|
|
150
150
|
ensure
|
|
151
151
|
if @owner
|
|
152
|
+
@task_runner.interrupt_all! if @task_runner.respond_to?(:interrupt_all!)
|
|
152
153
|
@relay&.stop
|
|
153
154
|
@lifecycle&.clear_pid
|
|
154
155
|
@state&.clear(pid: Process.pid) unless @rejected # a rejected daemon leaves its reason for `status`
|
|
@@ -220,7 +221,9 @@ module Diffbroker
|
|
|
220
221
|
rescan(client)
|
|
221
222
|
@usage_at = nil
|
|
222
223
|
client.perform("hello", "version" => VERSION, "platform" => Diffbroker.platform,
|
|
223
|
-
"service" => @lifecycle ? @lifecycle.service_installed? : false, "agent" => @agent
|
|
224
|
+
"service" => @lifecycle ? @lifecycle.service_installed? : false, "agent" => @agent,
|
|
225
|
+
# What this daemon is running: a run of this device that is missing here was lost with a restart.
|
|
226
|
+
"running" => @running_lock.synchronize { @running.to_a })
|
|
224
227
|
@out.puts "Connected. #{@repositories.size} repositories reported."
|
|
225
228
|
end
|
|
226
229
|
client.on_tick do
|
|
@@ -364,9 +367,8 @@ module Diffbroker
|
|
|
364
367
|
return unless @running_lock.synchronize { !@upgrading && @running.add?(id) } # the upgrade's restart would kill it
|
|
365
368
|
|
|
366
369
|
@state&.update(busy_tasks: @running_lock.synchronize { @running.size })
|
|
367
|
-
repositories = @repositories
|
|
368
370
|
@spawner.call do
|
|
369
|
-
@task_runner.run(message, repositories:)
|
|
371
|
+
@task_runner.run(message, repositories: known_repositories)
|
|
370
372
|
rescue StandardError => e
|
|
371
373
|
@out.puts "Task #{id} crashed: #{e.class}: #{e.message}"
|
|
372
374
|
ensure
|
|
@@ -377,6 +379,14 @@ module Diffbroker
|
|
|
377
379
|
end
|
|
378
380
|
end
|
|
379
381
|
|
|
382
|
+
# The server hands over pending tasks while the connection is still being set up, before the first scan: scan now rather
|
|
383
|
+
# than fail the task with "no checkout".
|
|
384
|
+
def known_repositories
|
|
385
|
+
@repositories = @scanner.scan if @scanned_at.nil?
|
|
386
|
+
@scanned_at ||= @clock.call
|
|
387
|
+
@repositories
|
|
388
|
+
end
|
|
389
|
+
|
|
380
390
|
# Helpers an agent left in worktrees nobody works in (rubocop --server and the like). Only while no task runs here.
|
|
381
391
|
def sweep_strays
|
|
382
392
|
return unless @reaper && @running_lock.synchronize { @running.empty? }
|
|
@@ -89,6 +89,16 @@ module Diffbroker
|
|
|
89
89
|
finished(id, "failed", 0, "agent_failed", e.message)
|
|
90
90
|
end
|
|
91
91
|
|
|
92
|
+
# The daemon is ending (stop, restart, upgrade). Its agents end with it, so none keeps working on a session the next companion
|
|
93
|
+
# continues, and nothing is reported as failed: the server hands the lost runs back when the next companion says hello.
|
|
94
|
+
def interrupt_all!
|
|
95
|
+
handles = @lock.synchronize do
|
|
96
|
+
@interrupted = true
|
|
97
|
+
@handles.values
|
|
98
|
+
end
|
|
99
|
+
handles.each { signal("TERM", _1.pid) }
|
|
100
|
+
end
|
|
101
|
+
|
|
92
102
|
# Spec §4.2 step 9: SIGINT to the agent's process group, SIGTERM after the grace period if it is still running.
|
|
93
103
|
def cancel(task_id)
|
|
94
104
|
# A cancel that lands between a verified run's two processes has no handle; remember it so the verifier never starts.
|
|
@@ -288,6 +298,8 @@ module Diffbroker
|
|
|
288
298
|
end
|
|
289
299
|
|
|
290
300
|
def finished(id, status, cost_usd, error_code, last_output)
|
|
301
|
+
return if @lock.synchronize { @interrupted }
|
|
302
|
+
|
|
291
303
|
last = last_output.to_s.lines.last.to_s.strip
|
|
292
304
|
@report.call("finished", { "task_id" => id, "status" => status, "cost_usd" => cost_usd, "error_code" => error_code,
|
|
293
305
|
"last_output" => last[0, MAX_OUTPUT] })
|
data/lib/diffbroker/version.rb
CHANGED