wurk 1.7.2 → 1.7.3
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/wurk/cli.rb +4 -0
- data/lib/wurk/rails_boot.rb +6 -0
- data/lib/wurk/version.rb +1 -1
- data/lib/wurk.rb +25 -0
- data/vendor/assets/dashboard/wurk-manifest.json +2 -2
- 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: de5a24063d924950bf14f06ba530215018d35acc33a069a9a6698f48602833fa
|
|
4
|
+
data.tar.gz: bcdf163c1de721563e707958f3487e2518f175a811143f84e48b070b55e4cacb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cc074e442e5987d123b86d9e02c8349840cd7c0b5e90d0cc5866b8e928f136e8d8ac5c861ffcf1c8a9243c0bb5e053f79a9b9477654d28b7728aadf7129957f3
|
|
7
|
+
data.tar.gz: 8c1ee815585ca13aef64a68d62b98e50288aeb989a98471177b4ddc94dfa8baddd33a74b42ff75eb92133b54e2da1c7f8ddbcb3403182ccda55112df33e2c6bd
|
data/lib/wurk/cli.rb
CHANGED
|
@@ -240,7 +240,11 @@ module Wurk
|
|
|
240
240
|
|
|
241
241
|
# --- run helpers ----------------------------------------------------
|
|
242
242
|
|
|
243
|
+
# Claim the worker boot before the host app loads, so the railtie's
|
|
244
|
+
# after_initialize hook knows this process already has a worker and does
|
|
245
|
+
# not fork a second one on top of it (#worker_boot_claimed?).
|
|
243
246
|
def enter_server_mode
|
|
247
|
+
Wurk.claim_worker_boot!
|
|
244
248
|
Wurk.enter_server_mode(@config)
|
|
245
249
|
end
|
|
246
250
|
|
data/lib/wurk/rails_boot.rb
CHANGED
|
@@ -42,8 +42,14 @@ module Wurk
|
|
|
42
42
|
# A process that won't run workers isn't a server: skip both server mode
|
|
43
43
|
# and the swarm boot. Console mode is detected reliably here — the console
|
|
44
44
|
# command file defines ::Rails::Console before initializers run.
|
|
45
|
+
#
|
|
46
|
+
# `Wurk.worker_boot_claimed?` covers the CLI: `bundle exec wurk` boots the
|
|
47
|
+
# host app itself and then runs a Launcher in this very process, so forking
|
|
48
|
+
# a swarm here as well would put two independent workers on one queue and
|
|
49
|
+
# run every job — every cron tick included — twice.
|
|
45
50
|
def skip_boot?
|
|
46
51
|
ENV['WURK_DISABLED'] == '1' ||
|
|
52
|
+
Wurk.worker_boot_claimed? ||
|
|
47
53
|
building? ||
|
|
48
54
|
defined?(::Rails::Console) ||
|
|
49
55
|
::Rails.env.test?
|
data/lib/wurk/version.rb
CHANGED
data/lib/wurk.rb
CHANGED
|
@@ -225,6 +225,31 @@ module Wurk
|
|
|
225
225
|
config[:server] = true
|
|
226
226
|
end
|
|
227
227
|
|
|
228
|
+
# True once something in THIS process has taken responsibility for running
|
|
229
|
+
# the workers. The CLI claims it before it boots the host application; the
|
|
230
|
+
# railtie's `after_initialize` hook reads it and stands down.
|
|
231
|
+
#
|
|
232
|
+
# Without the claim, `bundle exec wurk` inside a Rails app runs two
|
|
233
|
+
# independent workers: the CLI boots the app, the railtie forks a swarm
|
|
234
|
+
# from after_initialize, and then the CLI starts its own Launcher in the
|
|
235
|
+
# parent. Both drain the same queue, so every job runs twice — including
|
|
236
|
+
# every cron tick. See #claim_worker_boot!.
|
|
237
|
+
def worker_boot_claimed?
|
|
238
|
+
!!@worker_boot_claimed
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
# Claimed by the wurk/wurkswarm CLI. Not part of `enter_server_mode`: the
|
|
242
|
+
# railtie enters server mode too, and claiming there would make the railtie
|
|
243
|
+
# skip its own boot and run no workers at all.
|
|
244
|
+
def claim_worker_boot!
|
|
245
|
+
@worker_boot_claimed = true
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
# Test seam, matching `attr_writer :server` above: the claim is
|
|
249
|
+
# process-global, so a test that runs the CLI has to hand it back or it
|
|
250
|
+
# leaks into whatever test class shares the worker process next.
|
|
251
|
+
attr_writer :worker_boot_claimed
|
|
252
|
+
|
|
228
253
|
# Wurk ships Pro+Ent features in the free gem; these flags exist solely
|
|
229
254
|
# for third-party gems that branch on Sidekiq.pro? / Sidekiq.ent?.
|
|
230
255
|
def pro?
|