global_error_handler 0.1.1 → 0.1.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/README.md +7 -1
- data/lib/global_error_handler/version.rb +1 -1
- data/lib/tasks/global_error_handler.rake +31 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8fdb1574c39aa350dde0f8e6be54526e65940069
|
4
|
+
data.tar.gz: 2d3c783156410adb2b5b77029083920fda393f12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac108f47e998a5daccfc3b0665fe8df3fd78358baf5928a44b35ef73ab17fcbaa859de1337bf8626ed657907a1f33203910a645bab591c0e3177164c29298097
|
7
|
+
data.tar.gz: 140d3aa099996dcbdff08ba5fc5444a62d49d2490cd09f3416071e643d107812ba540857a6df5996cacbd6d43a0ee6404bd182c26fd117f66e4f2dcd68a34fbf
|
data/README.md
CHANGED
@@ -60,7 +60,13 @@ Following command should run on your server in case to automatically clear filte
|
|
60
60
|
Default expiration time is set to 4 weeks (`GlobalErrorHandler::Redis::REDIS_TTL`)
|
61
61
|
|
62
62
|
```ruby
|
63
|
-
|
63
|
+
rake global_error_handler:subscribe_to_expired
|
64
|
+
```
|
65
|
+
|
66
|
+
In case to stop subscription, run following below command
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
rake global_error_handler:unsubscribe_from_expired
|
64
70
|
```
|
65
71
|
|
66
72
|
## Data structure
|
@@ -1,6 +1,35 @@
|
|
1
1
|
namespace :global_error_handler do
|
2
2
|
desc 'Subscribe to expired keyevent notifications'
|
3
|
-
task :
|
4
|
-
|
3
|
+
task subscribe_to_expired: :environment do
|
4
|
+
puts '*** pid file exists!' or next if File.exists?(pid_file)
|
5
|
+
File.open(pid_file, 'w'){|f| f.puts Process.pid}
|
6
|
+
begin
|
7
|
+
GlobalErrorHandler::RedisNotificationSubscriber.subscribe!
|
8
|
+
ensure
|
9
|
+
File.unlink pid_file rescue nil
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
desc 'Unsubscribe from expired keyevent notifications'
|
14
|
+
task :unsubscribe_from_expired do
|
15
|
+
puts '*** pid file does not exist!' or next unless File.exists?(pid_file)
|
16
|
+
process_id = File.read(pid_file).to_i
|
17
|
+
begin
|
18
|
+
Process.kill 0, process_id
|
19
|
+
GlobalErrorHandler::RedisNotificationSubscriber.unsubscribe!
|
20
|
+
puts "** Terminating ##{process_id}..."
|
21
|
+
Timeout.timeout(10) { Process.kill 15, process_id }
|
22
|
+
rescue Timeout::Error
|
23
|
+
puts "** Killing ##{process_id} after waiting for 10 seconds..."
|
24
|
+
Process.kill 9, process_id
|
25
|
+
rescue Errno::ESRCH
|
26
|
+
puts "** No such process ##{process_id}. Exiting..."
|
27
|
+
ensure
|
28
|
+
File.unlink pid_file rescue nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def pid_file
|
33
|
+
@pid_file ||= File.expand_path('./tmp/pids/global_error_handler_subscription.pid')
|
5
34
|
end
|
6
35
|
end
|