multi_daemons 0.1.4 → 1.0.0

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
  SHA256:
3
- metadata.gz: dffea966b602d924ca26d77e1202c87b7c2392052471d7e27a0cf1a17abae5d7
4
- data.tar.gz: 28a0f94d79fc7fb6e612a41b6fd2d2a83731f846eeaead4e725f5a9cb255eeb0
3
+ metadata.gz: c2c2ba21525698d5998c83e65666a37e11974c06191619f356c195735c6ed9bf
4
+ data.tar.gz: aebfd0a037c7aa4d8fc127e893f56771b78beb8f5e44208aa5000eb4ed9efeb5
5
5
  SHA512:
6
- metadata.gz: 81afa3560717b5bc5d309d7c75ebaa6c8c667d1b29f87e1122b7f10bcec3e444f306953c04f8f84bad5c3b57ab063ddda1a5184844fb83e916b4d207ed4b758f
7
- data.tar.gz: 47ff8582405bd945f2f204d67d868b2ade4a324a621c9aa204192a9290992383aaf637e79653652b61b5941a977104676627fc54fbe907c9e03bafbe76fff104
6
+ metadata.gz: bea3e64a1cd62f4e96ef2da6141d3729a49873126780be17ba87d99e18502fc9b22ef0361aa0f4a9ef9e733cf99c1dde5fbf9eaa79d6153e26eb8e91dc7131d3
7
+ data.tar.gz: fd68ccd90b6b5105213b45bf1b8e9bcb5d9d52715d2280564ed68a0ff9db1698c2ab18e064ede61cc2fc7a96d9a508c72b2b477acebd73ae165d078a0e67820d
@@ -0,0 +1 @@
1
+ coverage
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2
4
+ sudo: false
5
+ notifications:
6
+ email:
7
+ - santhanakarthikeyan.s@gmail.com
8
+ on_success: always
9
+ on_failures: always
@@ -1,17 +1,24 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- multi_daemons (0.1.3)
4
+ multi_daemons (1.0.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
9
  byebug (10.0.2)
10
+ docile (1.3.1)
11
+ json (2.1.0)
10
12
  metaclass (0.0.4)
11
13
  minitest (5.11.3)
12
14
  mocha (1.7.0)
13
15
  metaclass (~> 0.0.1)
14
16
  rake (10.5.0)
17
+ simplecov (0.16.1)
18
+ docile (~> 1.1)
19
+ json (>= 1.8, < 3)
20
+ simplecov-html (~> 0.10.0)
21
+ simplecov-html (0.10.2)
15
22
 
16
23
  PLATFORMS
17
24
  ruby
@@ -23,6 +30,7 @@ DEPENDENCIES
23
30
  mocha (~> 1.7)
24
31
  multi_daemons!
25
32
  rake (~> 10.0)
33
+ simplecov
26
34
 
27
35
  BUNDLED WITH
28
36
  1.16.2
data/README.md CHANGED
@@ -67,12 +67,34 @@ looper = MultiDaemons::Daemon.new(proc_code, name: 'looper', type: :proc, option
67
67
  MultiDaemons.runner([looper], { force_kill_timeout: 60 })
68
68
  ```
69
69
 
70
+ We can even stop/start single daemon
71
+ ```ruby
72
+ ruby server.rb start looper
73
+
74
+ or
75
+
76
+ ruby server.rb stop looper
77
+ ```
78
+
79
+
70
80
  ### Supported options for runner:
71
81
  force_kill_timeout: <integer> # To kill all running daemons within the specified time.
72
82
 
73
83
  ### Supported option for Daemon:
74
84
  force_kill_timeout, log_dir, pid_dir
75
85
 
86
+ ### Error reporter
87
+
88
+ You may edit the error reporter to notify about any exception inside the daemon in a custom way. To notify Errbit or HoneyBadger use the following configuration
89
+
90
+ ```ruby
91
+ MultiDaemons.error_reporters = [ proc { |exception, _worker, context_hsh| Airbrake.notify(exception, context_hsh) } ]
92
+
93
+ or
94
+
95
+ MultiDaemons.error_reporters = [ proc { |exception, _worker, context_hsh| HoneyBadger.notify(exception, context_hsh) } ]
96
+ ```
97
+
76
98
  ## Development
77
99
 
78
100
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -8,7 +8,7 @@ module MultiDaemons
8
8
  @options = options
9
9
  unless ARGV[1].to_s.empty?
10
10
  @daemons = filter_daemons(daemons)
11
- puts "Daemon [#{ARGV[1]}] not exist. Availble ones are #{daemons.map(&:name)}" if @daemons.empty?
11
+ puts "Daemon [#{ARGV[1]}] not exist. Available ones are #{daemons.map(&:name)}" if @daemons.empty?
12
12
  end
13
13
  end
14
14
 
@@ -30,14 +30,12 @@ module MultiDaemons
30
30
  end
31
31
 
32
32
  def status
33
- daemon_attrs = []
33
+ daemon_attrs = {}
34
34
  daemons.each do |daemon|
35
- daemon_attrs << { name: daemon.name, pids: daemon.pids }
35
+ daemon.pids.each { |pid| daemon_attrs["#{daemon.name}-#{pid}"] = pid }
36
36
  end
37
- daemon_attrs.each do |hsh|
38
- hsh[:pids].each do |pid|
39
- puts "#{hsh[:name]}(#{pid}): #{print_status(Pid.running?(pid))}"
40
- end
37
+ daemon_attrs.each do |pid_name, pid|
38
+ puts "#{pid_name}: #{print_status(Pid.running?(pid))}"
41
39
  end
42
40
  end
43
41
 
@@ -45,7 +43,7 @@ module MultiDaemons
45
43
 
46
44
  def filter_daemons(daemons)
47
45
  daemon_names = ARGV[1].split(',')
48
- daemons.select{ |v| daemon_names.include?(v.name) }
46
+ daemons.select { |v| daemon_names.include?(v.name) }
49
47
  end
50
48
 
51
49
  def print_status(status)
@@ -59,26 +59,31 @@ module MultiDaemons
59
59
  "#{log_dir}#{name}.log"
60
60
  end
61
61
 
62
- def safe_fork
63
- Process.fork do
64
- begin
65
- Process.setsid
62
+ def process_fork
63
+ begin
64
+ Process.setsid
66
65
 
67
- $0 = name || $PROGRAM_NAME
66
+ $0 = name || $PROGRAM_NAME
68
67
 
69
- PidStore.store(pid_file, Process.pid)
68
+ PidStore.store(pid_file, Process.pid)
70
69
 
71
- log = File.new(log_file, 'a')
72
- STDIN.reopen '/dev/null'
73
- STDOUT.reopen log
74
- STDERR.reopen STDOUT
70
+ log = File.new(log_file, 'a')
71
+ STDIN.reopen '/dev/null'
72
+ STDOUT.reopen log
73
+ STDERR.reopen STDOUT
74
+ STDOUT.sync = true
75
75
 
76
- yield
77
- rescue Exception => e
78
- puts e.message
79
- puts e.backtrace
80
- ErrorReporter.report(e, class: self.class.name, name: name, type: type, options: options)
81
- end
76
+ yield if block_given?
77
+ rescue Exception => e
78
+ puts e.message
79
+ puts e.backtrace
80
+ ErrorReporter.report(e, class: self.class.name, name: name, type: type, options: options)
81
+ end
82
+ end
83
+
84
+ def safe_fork(&block)
85
+ Process.fork do
86
+ process_fork(&block)
82
87
  end
83
88
  end
84
89
 
@@ -1,3 +1,3 @@
1
1
  module MultiDaemons
2
- VERSION = '0.1.4'.freeze
2
+ VERSION = '1.0.0'.freeze
3
3
  end
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
 
11
11
  spec.summary = 'MultiDaemon provides an wrapper to run multiple daemon scripts'
12
12
  spec.description = 'MultiDaemon provides an warpper to run multiple daemon scripts which can be controlled by start/stop and restart commands'
13
- spec.homepage = %q{https://github.com/santhanakarthikeyan/multi_daemons}
13
+ spec.homepage = 'https://github.com/santhanakarthikeyan/multi_daemons'
14
14
  spec.license = 'MIT'
15
15
 
16
16
  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
@@ -35,4 +35,5 @@ Gem::Specification.new do |spec|
35
35
  spec.add_development_dependency 'minitest', '~> 5.0'
36
36
  spec.add_development_dependency 'mocha', '~> 1.7'
37
37
  spec.add_development_dependency 'rake', '~> 10.0'
38
+ spec.add_development_dependency 'simplecov'
38
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multi_daemons
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - santhanakarthikeyan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-12 00:00:00.000000000 Z
11
+ date: 2018-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  description: MultiDaemon provides an warpper to run multiple daemon scripts which
84
98
  can be controlled by start/stop and restart commands
85
99
  email:
@@ -88,6 +102,8 @@ executables: []
88
102
  extensions: []
89
103
  extra_rdoc_files: []
90
104
  files:
105
+ - ".gitignore"
106
+ - ".travis.yml"
91
107
  - CODE_OF_CONDUCT.md
92
108
  - CONTRIBUTING.md
93
109
  - Gemfile