process_handler 3.0.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 3e495c8a8ec6bf3798941bd11f2792b9a28f1c95
4
- data.tar.gz: 8923ae242c65ba6120b48184588b2534060ff831
2
+ SHA256:
3
+ metadata.gz: 28b012175863e19023e7c82aa8608deb778437ef4e7888c594516a8f2d6cc45e
4
+ data.tar.gz: a80e1ff6ce27c9bca5223a2d16861f0becf4fa951bc1cf9d4c4966fd20604737
5
5
  SHA512:
6
- metadata.gz: 337003df5486731c3b8addbb93e85159e664f20996fda1b22252e111d09831a1b735b3962f242f3f1ec44c88340025ca80356ebf468a1f610be5bc96b2870812
7
- data.tar.gz: 33b8e7e9d3d0f4368a53f11610449b0e5394177cf286495a52d843885e077425d3ff486621ae9a107c8ad2e05e91ec3550b7bea80f79b4de5436c5049379bfc4
6
+ metadata.gz: cc6b98cb72faf0ccd335e54578971f3378eeb1eac55a1f2b01b2c37011635e3ecba9762867a7ea4f74db0c9c68a905af3154585274e384b9c91a4efc934230bd
7
+ data.tar.gz: 750496c05ac0db4489a60ee9b2ddc8a317558e0177c3dd3adaef13711b46414aa58eaadb12a13406ffeeeb562c408fef93f7a5ea7ac6cf073f0e9001532f45fd
@@ -49,9 +49,9 @@ module Salemove
49
49
 
50
50
  def spawn_schedule(service, expression:, params:, overlap:)
51
51
  if params.empty?
52
- @scheduler.repeat expression, {overlap: overlap} { service.call }
52
+ @scheduler.repeat(expression, {overlap: overlap}) { service.call }
53
53
  else
54
- @scheduler.repeat expression, {overlap: overlap} { service.call(params) }
54
+ @scheduler.repeat(expression, {overlap: overlap}) { service.call(params) }
55
55
  end
56
56
  end
57
57
 
@@ -1,30 +1,17 @@
1
- require 'airbrake'
2
- require 'growl'
3
- require 'terminal-notifier'
4
-
5
1
  module Salemove
6
2
  module ProcessHandler
7
3
  class NotifierFactory
8
-
9
4
  def self.get_notifier(process_name, conf)
10
- if conf && conf[:type] == 'airbrake'
11
- notifier_name = conf[:notifier_name] || :default
12
- Airbrake.configure(notifier_name) do |airbrake|
13
- airbrake.environment = conf.fetch(:environment)
14
- airbrake.host = conf.fetch(:host)
15
- airbrake.project_id = conf.fetch(:project_id)
16
- airbrake.project_key = conf.fetch(:project_key)
17
- airbrake.ignore_environments = conf[:ignore_environments] if conf[:ignore_environments]
18
- airbrake.whitelist_keys = [
19
- /_HOST$/, /_TCP$/, /_UDP$/, /_PROTO$/, /_ADDR$/, 'PWD',
20
- 'GEM_HOME', 'PATH', 'SERVICE_NAME', 'RUBY_MAJOR', 'RUBY_VERSION',
21
- 'RACK_ENV', 'RUN_ENV', 'HOME', 'RUBYGEMS_VERSION', 'BUNDLER_VERSION'
22
- ]
23
- end
5
+ return nil unless conf
6
+
7
+ case conf[:type]
8
+ when 'airbrake'
24
9
  AirbrakeNotifier.new
25
- elsif conf && conf[:type] == 'growl'
10
+ when 'sentry'
11
+ SentryNotifier.new
12
+ when 'growl'
26
13
  GrowlNotifier.new(process_name)
27
- elsif conf && conf[:type] == 'terminal-notifier'
14
+ when 'terminal-notifier'
28
15
  TerminalNotifierWrapper.new(process_name)
29
16
  end
30
17
  end
@@ -36,6 +23,12 @@ module Salemove
36
23
  end
37
24
  end
38
25
 
26
+ class SentryNotifier
27
+ def notify_or_ignore(error, params)
28
+ Raven.capture_exception(error, extra: params)
29
+ end
30
+ end
31
+
39
32
  class GrowlNotifier
40
33
  def initialize(process_name)
41
34
  @process_name = process_name
@@ -1,5 +1,6 @@
1
1
  require 'benchmark'
2
2
  require 'securerandom'
3
+ require 'timeout'
3
4
  require_relative 'process_monitor'
4
5
  require_relative 'notifier_factory'
5
6
 
@@ -1,5 +1,5 @@
1
1
  module Salemove
2
2
  module ProcessHandler
3
- VERSION = '3.0.0'
3
+ VERSION = '4.0.0'
4
4
  end
5
5
  end
@@ -17,10 +17,4 @@ Gem::Specification.new do |spec|
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
-
21
- spec.add_dependency 'airbrake', '~> 7.4'
22
- spec.add_dependency 'timers', '~> 4.1.2'
23
- spec.add_dependency 'sucker_punch', '~> 1.1' # for async airbrake notifications
24
- spec.add_dependency 'growl'
25
- spec.add_dependency 'terminal-notifier'
26
20
  end
@@ -1,3 +1,4 @@
1
+ require 'logger'
1
2
  require 'salemove/process_handler'
2
3
  require 'salemove/process_handler/composite_process'
3
4
  require 'salemove/process_handler/cron_process'
metadata CHANGED
@@ -1,85 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: process_handler
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - SaleMove TechMovers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-16 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: airbrake
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '7.4'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '7.4'
27
- - !ruby/object:Gem::Dependency
28
- name: timers
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: 4.1.2
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: 4.1.2
41
- - !ruby/object:Gem::Dependency
42
- name: sucker_punch
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '1.1'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '1.1'
55
- - !ruby/object:Gem::Dependency
56
- name: growl
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: terminal-notifier
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
11
+ date: 2019-03-29 00:00:00.000000000 Z
12
+ dependencies: []
83
13
  description: This gem helps to monitor and manage processes
84
14
  email:
85
15
  - techmovers@salemove.com
@@ -107,7 +37,6 @@ files:
107
37
  - process_handler.gemspec
108
38
  - spec/fixtures/composite_service.rb
109
39
  - spec/fixtures/cron_service.rb
110
- - spec/process_handler/airbrake_spec.rb
111
40
  - spec/process_handler/composite_process_spec.rb
112
41
  - spec/process_handler/cron_process_spec.rb
113
42
  - spec/process_handler/pivot_process_spec.rb
@@ -132,14 +61,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
61
  version: '0'
133
62
  requirements: []
134
63
  rubyforge_project:
135
- rubygems_version: 2.2.5
64
+ rubygems_version: 2.7.6
136
65
  signing_key:
137
66
  specification_version: 4
138
67
  summary: ''
139
68
  test_files:
140
69
  - spec/fixtures/composite_service.rb
141
70
  - spec/fixtures/cron_service.rb
142
- - spec/process_handler/airbrake_spec.rb
143
71
  - spec/process_handler/composite_process_spec.rb
144
72
  - spec/process_handler/cron_process_spec.rb
145
73
  - spec/process_handler/pivot_process_spec.rb
@@ -1,61 +0,0 @@
1
- require 'spec_helper'
2
- require 'salemove/process_handler/notifier_factory'
3
- require 'securerandom'
4
-
5
- describe 'Airbrake configuration' do
6
- let(:environment) { 'SOME_ENVIRONMENT' }
7
- let(:config) { airbrake_config.merge(type: 'airbrake') }
8
- let(:airbrake_config) { base_params }
9
- let(:base_params) do
10
- {
11
- environment: environment,
12
- host: 'localhost',
13
- project_id: '123456',
14
- project_key: 'abc123',
15
- ignore_environments: ['dev'],
16
- # Airbrake module raises an error when same notifier configured multiple times
17
- # Provide a random notifier name for each test case
18
- notifier_name: SecureRandom.hex
19
- }
20
- end
21
- let(:airbrake) do
22
- ProcessHandler::NotifierFactory.get_notifier('Process name', config)
23
- end
24
-
25
- context 'when all params set' do
26
- it 'does not raise an error' do
27
- expect { airbrake }.not_to raise_error
28
- end
29
- end
30
-
31
- context 'when project_id is not a number' do
32
- let(:airbrake_config) { base_params.merge(project_id: 'abc') }
33
-
34
- it 'raises error' do
35
- expect { airbrake }.to raise_error
36
- end
37
- end
38
-
39
- context 'when ignore_environments missing' do
40
- before { base_params.delete(:ignore_environments) }
41
-
42
- it 'does not raise an error' do
43
- expect { airbrake }.not_to raise_error
44
- end
45
- end
46
-
47
- shared_examples_for 'raises error if config param missing' do |key|
48
- context "when #{key} missing" do
49
- before { base_params.delete(key) }
50
-
51
- it 'raises error' do
52
- expect { airbrake }.to raise_error
53
- end
54
- end
55
- end
56
-
57
- it_behaves_like 'raises error if config param missing', :environment
58
- it_behaves_like 'raises error if config param missing', :host
59
- it_behaves_like 'raises error if config param missing', :project_id
60
- it_behaves_like 'raises error if config param missing', :project_key
61
- end