global_error_handler 0.2.0 → 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/README.md +37 -3
- data/config/templates/geh_subscription_init.sh.erb +34 -0
- data/global_error_handler.gemspec +2 -2
- data/lib/global_error_handler/version.rb +1 -1
- data/lib/recipes/global_error_handler.rb +26 -3
- metadata +21 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c3839e0cb72ce4348b001259ca8fe678f57a8d5
|
4
|
+
data.tar.gz: 0cd927a13f6b8fceb7fc2b2d674ae214d22f5dd9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72f729fa6902dbbd5f8622e1f85236bf9db32e175e44f36261c0bf7a75a9a8577201aa578baf99e18c99fa4fb02ee2011a03f0247942ce5d1ed015e0a64308ad
|
7
|
+
data.tar.gz: 486a16fb83959678c0df95b2e562b0ccde715cf865ec16d31f25cada0c6afb45f0e6f919109c13cd0783128cbebc9542f77fb21aa19f54af6199dd7ac855466f
|
data/README.md
CHANGED
@@ -11,8 +11,10 @@ It adds Exceptions tab to Redis Web server in case to view, filter, delete or tr
|
|
11
11
|
- [RescueFrom](#rescue_from)
|
12
12
|
- [Subscribe to Redis notifications](#subscribe-to-redis-notifications)
|
13
13
|
- [Data structure](#data-structure)
|
14
|
+
- [Database consistency](#database-consistency)
|
14
15
|
- [Contributing](#contributing)
|
15
16
|
|
17
|
+
|
16
18
|
## Installation
|
17
19
|
|
18
20
|
Add this line to your application's Gemfile:
|
@@ -27,10 +29,12 @@ Or install it yourself as:
|
|
27
29
|
|
28
30
|
$ gem install global_error_handler
|
29
31
|
|
32
|
+
|
30
33
|
## Configuration
|
31
34
|
|
32
35
|
Add redis database configuration into `global_exceptions_handler` section of _redis.yml_. See [redis_example.yml](https://github.com/kolobock/global_error_handler/blob/master/config/redis_example.yml) for more details.
|
33
36
|
|
37
|
+
|
34
38
|
## Usage
|
35
39
|
|
36
40
|
### Exceptions tab
|
@@ -57,6 +61,7 @@ GlobalErrorHandler::Handler.new(request.env, exception).process_exception!
|
|
57
61
|
```
|
58
62
|
|
59
63
|
### Subscribe to Redis notifications
|
64
|
+
#### rake tasks
|
60
65
|
Following command should run on your server in case to automatically clear filters on deleting keys from redis due to expiration.
|
61
66
|
Default expiration time is set to 4 weeks (`GlobalErrorHandler::Redis::REDIS_TTL`)
|
62
67
|
|
@@ -70,21 +75,42 @@ In case to stop subscription, run following below command
|
|
70
75
|
rake global_error_handler:unsubscribe_from_expired
|
71
76
|
```
|
72
77
|
|
78
|
+
#### capistrano tasks
|
73
79
|
There are Capistrano recipes that run desired rake tasks on the remote server
|
74
80
|
* global_error_handler:subscribe
|
75
81
|
* global_error_handler:unsubscribe
|
76
82
|
* global_error_handler:update_subscription
|
77
83
|
|
84
|
+
In case to subscribe automatically after being deployed, add following require into `deploy.rb`
|
85
|
+
|
78
86
|
```ruby
|
87
|
+
require 'global_error_handler/capistrano_recipes'
|
79
88
|
after 'deploy:restart', 'global_error_handler:update_subscription'
|
80
89
|
```
|
81
90
|
|
82
|
-
|
91
|
+
#### init.d script
|
92
|
+
Subscribe to expiration keys should run on system start-up as well after you system has been restarted
|
93
|
+
so there is an init.d script to do it. Note that script is for RedHat/CentOS systems only (chkconfig-dependent)!
|
83
94
|
|
84
|
-
|
85
|
-
|
95
|
+
To generate init.d script run following:
|
96
|
+
|
97
|
+
```bash
|
98
|
+
cap <RAILS_ENV> global_error_handler:initd:setup
|
86
99
|
```
|
87
100
|
|
101
|
+
To install init.d script run following:
|
102
|
+
|
103
|
+
```bash
|
104
|
+
cap <RAILS_ENV> global_error_handler:initd:install
|
105
|
+
```
|
106
|
+
|
107
|
+
To uninstall init.d script run following:
|
108
|
+
|
109
|
+
```bash
|
110
|
+
cap <RAILS_ENV> global_error_handler:initd:uninstall
|
111
|
+
```
|
112
|
+
|
113
|
+
|
88
114
|
## Data structure
|
89
115
|
Redis database data structure contains following below keys:
|
90
116
|
- 'global_error_handler:current_id' : *STRING* - stores current id of an exception. It is being incremented on adding new exception into database
|
@@ -103,6 +129,14 @@ Redis database data structure contains following below keys:
|
|
103
129
|
- timestamp - time when exception was raised
|
104
130
|
- 'global_error_handler:filter:\<field\>:\<filter\>' : *LIST* - stores exception' keys that are filtered by field and filter. where \<field\>: either `error_class` or `error_message`, \<filter\>: string stored in the appropriated attribute.
|
105
131
|
|
132
|
+
### Database consistency
|
133
|
+
To check the database consistency, there is a rake task that will check for filters without the keys assigned with.
|
134
|
+
|
135
|
+
```bash
|
136
|
+
rake global_error_handler:cleanup_database_dependencies
|
137
|
+
```
|
138
|
+
|
139
|
+
|
106
140
|
## Contributing
|
107
141
|
|
108
142
|
1. Fork it ( https://github.com/kolobock/global_error_handler/fork )
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
# chkconfig: 345 99 15
|
3
|
+
# description: script to start <%= application %> geh_subscription
|
4
|
+
# /etc/init.d/<%= application %>_geh_subscription
|
5
|
+
|
6
|
+
start() {
|
7
|
+
su - <%= user %> -c "cd <%= current_path %>; PATH=$PATH:/home/<%= user %>/.rvm/bin; RAILS_ENV=<%= rails_env %> nohup rvm <%= rvm_ruby_string %> do rake global_error_handler:cleanup_database_dependencies >/dev/null 2>&1 & sleep 2"
|
8
|
+
su - <%= user %> -c "cd <%= current_path %>; PATH=$PATH:/home/<%= user %>/.rvm/bin; RAILS_ENV=<%= rails_env %> nohup rvm <%= rvm_ruby_string %> do rake global_error_handler:subscribe_to_expired >/dev/null 2>&1 & sleep 3"
|
9
|
+
}
|
10
|
+
|
11
|
+
stop() {
|
12
|
+
su - <%= user %> -c "cd <%= current_path %>; PATH=$PATH:<%= rvm_bin_path %>; RAILS_ENV=<%= rails_env %> rvm <%= rvm_ruby_string %> do rake global_error_handler:unsubscribe_from_expired"
|
13
|
+
}
|
14
|
+
|
15
|
+
case "$1" in
|
16
|
+
start)
|
17
|
+
echo "calling ${1} on <%= application %> Global Error Handler Subscription ... "
|
18
|
+
start
|
19
|
+
;;
|
20
|
+
stop)
|
21
|
+
echo "calling ${1} on <%= application %> Global Error Handler Subscription ... "
|
22
|
+
stop
|
23
|
+
;;
|
24
|
+
restart)
|
25
|
+
echo "calling ${1} on <%= application %> Global Error Handler Subscription ... "
|
26
|
+
stop
|
27
|
+
start
|
28
|
+
;;
|
29
|
+
*)
|
30
|
+
echo "Usage: $0 {start|stop|restart}"
|
31
|
+
exit 1
|
32
|
+
esac
|
33
|
+
|
34
|
+
exit $?
|
@@ -19,8 +19,8 @@ Gem::Specification.new do |spec|
|
|
19
19
|
|
20
20
|
spec.add_development_dependency "bundler", '~> 1.6'
|
21
21
|
spec.add_development_dependency "rake", '~> 10.3', '>= 10.3.2'
|
22
|
+
spec.add_development_dependency "capistrano", "< 3.0"
|
22
23
|
|
23
24
|
spec.add_dependency 'resque', '~> 1.25', '>= 1.25.1'
|
24
|
-
spec.add_dependency 'haml', '~> 4.0', '>= 4.0.5'
|
25
|
-
spec.add_runtime_dependency "capistrano", "< 3.0"
|
25
|
+
spec.add_dependency 'haml', '~> 4.0', '>= 4.0.5', '< 4.1'
|
26
26
|
end
|
@@ -5,12 +5,13 @@ module GlobalErrorHandler
|
|
5
5
|
namespace :global_error_handler do
|
6
6
|
desc 'Subscribe to expiration'
|
7
7
|
task :subscribe do
|
8
|
-
run %Q{cd #{
|
8
|
+
run %Q{cd #{current_path} && RAILS_ENV=#{rails_env} nohup rake global_error_handler:cleanup_database_dependencies >/dev/null 2>&1 & sleep 2}
|
9
|
+
run %Q{cd #{current_path} && RAILS_ENV=#{rails_env} nohup rake global_error_handler:subscribe_to_expired >/dev/null 2>&1 & sleep 3}
|
9
10
|
end
|
10
11
|
|
11
12
|
desc 'Unsubscribe from expiration'
|
12
13
|
task :unsubscribe do
|
13
|
-
run %Q{cd #{
|
14
|
+
run %Q{cd #{current_path} && RAILS_ENV=#{rails_env} #{rake} global_error_handler:unsubscribe_from_expired}
|
14
15
|
end
|
15
16
|
|
16
17
|
desc 'Update Subscription to expiration'
|
@@ -18,7 +19,29 @@ module GlobalErrorHandler
|
|
18
19
|
unsubscribe
|
19
20
|
subscribe
|
20
21
|
end
|
21
|
-
|
22
|
+
|
23
|
+
namespace :initd do
|
24
|
+
desc 'Generate geh_subscription init.d script'
|
25
|
+
task :setup, roles: :app do
|
26
|
+
run "mkdir -p #{shared_path}/config"
|
27
|
+
location = File.expand_path('../../../config/templates/geh_subscription_init.sh.erb', __FILE__)
|
28
|
+
config = ERB.new(File.read(location))
|
29
|
+
put config.result(binding), "#{shared_path}/config/#{application}_geh_subscription_init.sh"
|
30
|
+
end
|
31
|
+
|
32
|
+
desc 'Copy geh_subscription into an init.d and adds to chkconfig'
|
33
|
+
task :install, roles: :app do
|
34
|
+
sudo "cp #{shared_path}/config/#{application}_geh_subscription_init.sh /etc/init.d/#{application}_geh_subscription;\
|
35
|
+
sudo chmod +x /etc/init.d/#{application}_geh_subscription;\
|
36
|
+
sudo chkconfig --add #{application}_geh_subscription", pty: true
|
37
|
+
end
|
38
|
+
|
39
|
+
desc 'Removes geh_subscription from an init.d and deletes from chkconfig'
|
40
|
+
task :uninstall, roles: :app do
|
41
|
+
sudo "chkconfig --del #{application}_geh_subscription;\
|
42
|
+
sudo rm -f /etc/init.d/#{application}_geh_subscription", pty: true
|
43
|
+
end
|
44
|
+
end
|
22
45
|
end
|
23
46
|
end
|
24
47
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: global_error_handler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrii Rudenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -44,6 +44,20 @@ dependencies:
|
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: 10.3.2
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: capistrano
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "<"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '3.0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "<"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '3.0'
|
47
61
|
- !ruby/object:Gem::Dependency
|
48
62
|
name: resque
|
49
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -74,6 +88,9 @@ dependencies:
|
|
74
88
|
- - ">="
|
75
89
|
- !ruby/object:Gem::Version
|
76
90
|
version: 4.0.5
|
91
|
+
- - "<"
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '4.1'
|
77
94
|
type: :runtime
|
78
95
|
prerelease: false
|
79
96
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -84,20 +101,9 @@ dependencies:
|
|
84
101
|
- - ">="
|
85
102
|
- !ruby/object:Gem::Version
|
86
103
|
version: 4.0.5
|
87
|
-
- !ruby/object:Gem::Dependency
|
88
|
-
name: capistrano
|
89
|
-
requirement: !ruby/object:Gem::Requirement
|
90
|
-
requirements:
|
91
|
-
- - "<"
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version: '3.0'
|
94
|
-
type: :runtime
|
95
|
-
prerelease: false
|
96
|
-
version_requirements: !ruby/object:Gem::Requirement
|
97
|
-
requirements:
|
98
104
|
- - "<"
|
99
105
|
- !ruby/object:Gem::Version
|
100
|
-
version: '
|
106
|
+
version: '4.1'
|
101
107
|
description: On the middleware level catch an exception from Rails app and store in
|
102
108
|
the separated Redis database.
|
103
109
|
email:
|
@@ -112,6 +118,7 @@ files:
|
|
112
118
|
- README.md
|
113
119
|
- Rakefile
|
114
120
|
- config/redis_example.yml
|
121
|
+
- config/templates/geh_subscription_init.sh.erb
|
115
122
|
- global_error_handler.gemspec
|
116
123
|
- lib/global_error_handler.rb
|
117
124
|
- lib/global_error_handler/app_exception.rb
|