midget_jobs 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +18 -0
- data/lib/midget_jobs/version.rb +1 -1
- data/lib/models/concerns/postgres_notifications_listener.rb +9 -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: f31ce7256430433d6371404650a9a13eed0e22bcabf74dae66fad28ede2a037c
|
4
|
+
data.tar.gz: 70dd350c6c5ab4c64048e7dd120f9f7a8ab0e5586808a101df1dd4a04b27a859
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3eadc0b0adf4aa7eb624e1a0544ce985d1740e912793363b54bced5cc0cab9ba741e4a71bf8b126fccd9999905d94cfb48f49f1299f7c4f19c9fd92698c33309
|
7
|
+
data.tar.gz: 603cb4139df7662a141acb2fdd1966a2875af20e4ed4bce843b1ed1422731ac10455bee3af9a51775cb2fa5f8847ea2bfb65db5d25890256fc0e66ec81d5c0ee
|
data/README.md
CHANGED
@@ -30,6 +30,24 @@ Then run
|
|
30
30
|
$ rails generate midget_jobs:install
|
31
31
|
|
32
32
|
This generator creates an initializer file at config/initializers and migrations to db/migrate
|
33
|
+
|
34
|
+
#### With Puma's multiple workers on production
|
35
|
+
|
36
|
+
In file `config/initializers/midget_jobs.rb` disable start with puma:
|
37
|
+
|
38
|
+
...
|
39
|
+
if Rails.const_defined?('Server')# || $0.include?('puma')
|
40
|
+
|
41
|
+
In file `config/puma/production.rb` update `on_worker_boot do` block as:
|
42
|
+
|
43
|
+
...
|
44
|
+
on_worker_boot do
|
45
|
+
ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
|
46
|
+
Rails.logger.debug 'on_worker_boot starting jobs'
|
47
|
+
|
48
|
+
MidgetJobs.initialize_workers
|
49
|
+
...
|
50
|
+
end
|
33
51
|
|
34
52
|
## Usage
|
35
53
|
|
data/lib/midget_jobs/version.rb
CHANGED
@@ -13,8 +13,16 @@ module PostgresNotificationsListener
|
|
13
13
|
Rails.logger.info "postgres #{event.inspect}, pid: #{pid.inspect}, data: #{data.inspect}"
|
14
14
|
process_notification(data)
|
15
15
|
end
|
16
|
+
rescue ActiveRecord::StatementInvalid => e
|
17
|
+
Rails.logger.error "Ex #{name} listening_job wait_for_notify #{e}-retrying!"
|
18
|
+
if e.to_s.include?('PG::ConnectionBad')
|
19
|
+
Rails.logger.error "Reestablish AR connection..."
|
20
|
+
ActiveRecord::Base.connection.verify!
|
21
|
+
end
|
22
|
+
sleep 0.1
|
23
|
+
retry
|
16
24
|
rescue StandardError => e
|
17
|
-
Rails.logger.error "
|
25
|
+
Rails.logger.error "Ex #{name} listening_job wait_for_notify #{e}-retrying!"
|
18
26
|
retry
|
19
27
|
end
|
20
28
|
end.abort_on_exception = true
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: midget_jobs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- josefchmel
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|