belated 0.3.1 → 0.3.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/.gitignore +2 -1
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/README.md +9 -5
- data/lib/belated.rb +16 -5
- data/lib/belated/version.rb +1 -1
- data/lib/belated/worker.rb +3 -2
- metadata +2 -3
- data/hard_worker_dump +0 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 995560f345bb7644aa19035b27a68d43a1210ee36c21d13e21cc430b76d9fded
|
|
4
|
+
data.tar.gz: 103441a7e60e79319c65bacbedfb4dc337224c41c0e9560225f3b2421e219473
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ecc27c208d2fdb26c93ee39ebba7ada11236e9f564565d69258dfa6381a407c924e076365329f088ca4071955fd0eaeb8e9e1a1119f77d824473987590fee670
|
|
7
|
+
data.tar.gz: 57db27785351cbba33b6c704f877eacf4343d95a02267411e79bf63f1efadb49a67430342d145898a8571318bc61eafdd756bc2618388603122a0733bad7a3ed
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -10,19 +10,23 @@ It uses dRuby to do the communication! Which is absolute great. No need for Redi
|
|
|
10
10
|
|
|
11
11
|
TODO LIST:
|
|
12
12
|
|
|
13
|
-
- ~~Marshal the job queue into a file so you don't lose all progress~~
|
|
14
|
-
(Ended up using YAML)
|
|
15
13
|
- Catch SIGTERM and friends
|
|
16
|
-
-
|
|
17
|
-
- ~~Parse options from command line, eg. `--workers 10`~~(Done!)
|
|
14
|
+
- Now supports it, partly.
|
|
18
15
|
- Don't crash on errors (Partially done)
|
|
19
|
-
- ~~Add a logger~~
|
|
20
16
|
- Make it possible to schedule jobs
|
|
21
17
|
- Maybe support ActiveJob?
|
|
22
18
|
- Have a web UI
|
|
23
19
|
- Do some performance testing
|
|
24
20
|
- Add a section telling people to use Sidekiq if they can
|
|
25
21
|
|
|
22
|
+
DONE
|
|
23
|
+
|
|
24
|
+
- ~~Marshal the job queue into a file so you don't lose all progress~~
|
|
25
|
+
(Ended up using YAML)
|
|
26
|
+
- ~~Add a logger~~
|
|
27
|
+
- ~~Support Rails~~ (Supported!)
|
|
28
|
+
- ~~Parse options from command line, eg. `--workers 10`~~(Done!)
|
|
29
|
+
|
|
26
30
|
## Installation
|
|
27
31
|
|
|
28
32
|
Add this line to your application's Gemfile:
|
data/lib/belated.rb
CHANGED
|
@@ -36,8 +36,7 @@ class Belated
|
|
|
36
36
|
# Aliased for testing purposes.
|
|
37
37
|
# This is only run from the bin file.
|
|
38
38
|
def start
|
|
39
|
-
boot_app
|
|
40
|
-
load_jobs
|
|
39
|
+
boot_app && load_jobs
|
|
41
40
|
@worker_list = []
|
|
42
41
|
Belated.config.workers.times do |_i|
|
|
43
42
|
@worker_list << Thread.new { Worker.new }
|
|
@@ -46,6 +45,7 @@ class Belated
|
|
|
46
45
|
|
|
47
46
|
connect!
|
|
48
47
|
banner_and_info
|
|
48
|
+
trap_signals
|
|
49
49
|
DRb.thread.join
|
|
50
50
|
end
|
|
51
51
|
alias initialize start
|
|
@@ -55,12 +55,22 @@ class Belated
|
|
|
55
55
|
DRb.start_service(URI, @@queue, verbose: true)
|
|
56
56
|
rescue DRb::DRbConnError, Errno::EADDRINUSE
|
|
57
57
|
Belated.logger.error 'Could not connect to DRb server.'
|
|
58
|
-
uri = "druby://localhost:#{Array.new(4) { rand(10) }.join}"
|
|
59
|
-
self.class.send(:remove_const, 'URI')
|
|
60
|
-
self.class.const_set('URI', uri)
|
|
61
58
|
retry
|
|
62
59
|
end
|
|
63
60
|
|
|
61
|
+
def trap_signals
|
|
62
|
+
%w[INT TERM].each do |signal|
|
|
63
|
+
Signal.trap(signal) do
|
|
64
|
+
@worker_list.length.times do
|
|
65
|
+
@@queue.push(:shutdown)
|
|
66
|
+
end
|
|
67
|
+
Thread.new { stop_workers }
|
|
68
|
+
sleep 0.1 until @@queue.empty?
|
|
69
|
+
exit
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
64
74
|
def boot_app
|
|
65
75
|
return unless rails?
|
|
66
76
|
|
|
@@ -92,6 +102,7 @@ class Belated
|
|
|
92
102
|
|
|
93
103
|
def stop_workers
|
|
94
104
|
@worker_list&.each do |worker|
|
|
105
|
+
sleep 0.1 if worker.alive?
|
|
95
106
|
Thread.kill(worker)
|
|
96
107
|
end
|
|
97
108
|
class_array = []
|
data/lib/belated/version.rb
CHANGED
data/lib/belated/worker.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: belated
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sampo Kuokkanen
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-07-
|
|
11
|
+
date: 2021-07-31 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: drb
|
|
@@ -78,7 +78,6 @@ files:
|
|
|
78
78
|
- bin/bundle
|
|
79
79
|
- bin/console
|
|
80
80
|
- bin/setup
|
|
81
|
-
- hard_worker_dump
|
|
82
81
|
- lib/belated.rb
|
|
83
82
|
- lib/belated/client.rb
|
|
84
83
|
- lib/belated/logging.rb
|
data/hard_worker_dump
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
--- []
|