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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 021058fb2e16494420f894d4b003ea13767b6776
4
- data.tar.gz: 3bce861045678fc0bbafbadfe912764a7ac2b15b
3
+ metadata.gz: 8fdb1574c39aa350dde0f8e6be54526e65940069
4
+ data.tar.gz: 2d3c783156410adb2b5b77029083920fda393f12
5
5
  SHA512:
6
- metadata.gz: a5fcbf7e3f37cc1de6cf258876e8632cd2fd9e8a5341d954952dace47e8d9eb952acf31f126245bf05c40366b46bb939e3b5b13027150bb8aae2888c143e5946
7
- data.tar.gz: 7d6d0d1d0f67e9b0015753ff990555e80a1ad3df0753269ca0bb3e50733e47ad2a402bd3aeb8f582552fd97aac7b2de015f32b30e311834e7abb38ab76d84b65
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
- GlobalErrorHandler::RedisNotificationSubscriber.subscribe!
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,3 +1,3 @@
1
1
  module GlobalErrorHandler
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -1,6 +1,35 @@
1
1
  namespace :global_error_handler do
2
2
  desc 'Subscribe to expired keyevent notifications'
3
- task :subscribe_to_expired do
4
- GlobalErrorHandler::RedisNotificationSubscriber.subscribe!
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: global_error_handler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrii Rudenko