bmc-daemon-lib 0.3.3 → 0.3.4

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
2
  SHA1:
3
- metadata.gz: 826aca4700b96e6c320465e8388578e812ff513a
4
- data.tar.gz: 567c3d41d7dd19b411541af24f3a39eb36fac41f
3
+ metadata.gz: 07d8df6da72c6e6fdaafac2a1a67b78ecf760859
4
+ data.tar.gz: 8f64f4c0c20bf983b5e1bb4ba4e0272737a5ec20
5
5
  SHA512:
6
- metadata.gz: 46bbd87ecd0cba8321627351f27de47938014575376e97e5ea3de699556f1c3daad295284c2949ba50595b5683ff86fc1d68a17c06fb882ae44fe4cbccf428cb
7
- data.tar.gz: 25fc999116f48f10ae98df12ce9a7fb706d5a649b97003eb2345f6108e58b85670552fa4f2cb4f0766f63d6703d7ed0112d4690a7a8b7f3d7670375e2e0e50d4
6
+ metadata.gz: 350eec5594f1353e43f7929f03eac494de915c9d29c91e3c4f507f7d736399cc23e7b409651c3be26db0dff826ca3c8c20a37f8f02fcb73685fdc3dbed05fd0f
7
+ data.tar.gz: a938502ae7175af87becfe05990994a18fa7f1e6f659911d162a550be18628d10deb012b772ccd314a840fd4c8c33c9d65651490175665e3bd3b5766c38aade0
data/Gemfile.lock CHANGED
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bmc-daemon-lib (0.3.3)
4
+ bmc-daemon-lib (0.3.4)
5
5
  chamber (~> 2.9)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
10
  ast (2.3.0)
11
- chamber (2.9.0)
11
+ chamber (2.9.1)
12
12
  hashie (~> 3.3)
13
13
  thor (~> 0.19.1)
14
14
  diff-lcs (1.2.5)
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
2
  Gem::Specification.new do |spec|
3
3
  # Project version
4
- spec.version = "0.3.3"
4
+ spec.version = "0.3.4"
5
5
 
6
6
  # Project description
7
7
  spec.name = "bmc-daemon-lib"
@@ -81,10 +81,7 @@ module BmcDaemonLib
81
81
  Encoding.default_external = "utf-8"
82
82
 
83
83
  # Init New Relic
84
- logs_newrelic = Conf.at :logs, :newrelic
85
- logs_path = Conf.at :logs, :path
86
- newrelic_logfile = File.expand_path logs_newrelic.to_s, logs_path.to_s
87
- prepare_newrelic self[:newrelic], newrelic_logfile
84
+ prepare_newrelic self[:newrelic]
88
85
 
89
86
  # Try to access any key to force parsing of the files
90
87
  self[:dummy]
@@ -112,6 +109,23 @@ module BmcDaemonLib
112
109
  path.reduce(Conf) { |m, key| m && m[key.to_s] }
113
110
  end
114
111
 
112
+ def self.logfile_path pipe
113
+ # Access configuration
114
+ path = Conf.at :logs, :path
115
+ specific = Conf.at :logs, pipe
116
+ default = Conf.at :logs, :default
117
+
118
+ # Ignore if explicitely disabled
119
+ return nil if specific.nil?
120
+
121
+ # Fallback on default path if not provided,
122
+ specific ||= default
123
+ specific ||= "default.log"
124
+
125
+ # Build logfile_path
126
+ File.expand_path specific.to_s, path.to_s
127
+ end
128
+
115
129
  def self.newrelic_enabled?
116
130
  ensure_init
117
131
  !! (self[:newrelic] && self[:newrelic][:license])
@@ -145,7 +159,6 @@ module BmcDaemonLib
145
159
  config_etc = self.generate(:config_etc)
146
160
 
147
161
  "A default configuration is available (#{config_defaults}) and can be copied to the default location (#{config_etc}): \n sudo cp #{config_defaults} #{config_etc}"
148
-
149
162
  end
150
163
  end
151
164
 
@@ -160,7 +173,7 @@ module BmcDaemonLib
160
173
  @files << File.expand_path(path) if path && File.readable?(path)
161
174
  end
162
175
 
163
- def self.prepare_newrelic section, logfile
176
+ def self.prepare_newrelic section
164
177
  # Disable NewRelic if no config present
165
178
  return unless self.newrelic_enabled?
166
179
 
@@ -168,8 +181,8 @@ module BmcDaemonLib
168
181
  GC::Profiler.enable
169
182
 
170
183
  # Set logfile, license, monitor mode
171
- ENV["NEW_RELIC_LOG"] = logfile.to_s if logfile
172
- ENV["NEW_RELIC_LICENSE_KEY"] = section[:license].to_s
184
+ ENV["NEW_RELIC_LOG"] = logfile_path(:newrelic)
185
+ ENV["NEW_RELIC_LICENSE_KEY"] = section[:license].to_s
173
186
  ENV["NEW_RELIC_MONITOR_MODE"] = "true"
174
187
 
175
188
  # Build NewRelic app_name if not provided as-is
@@ -181,7 +194,7 @@ module BmcDaemonLib
181
194
  text = stack.join('-')
182
195
  section[:app_name] = "#{text}; #{text}-#{host}"
183
196
  end
184
- ENV["NEW_RELIC_APP_NAME"] = section[:app_name].to_s
197
+ ENV["NEW_RELIC_APP_NAME"] = section[:app_name].to_s
185
198
 
186
199
  # Enable module
187
200
  ENV["NEWRELIC_AGENT_ENABLED"] = "true"
@@ -193,12 +206,6 @@ module BmcDaemonLib
193
206
  unless @initialized
194
207
  fail ConfigInitiRequired, "ensure_init: Conf.init(app_root) should be invoked beforehand"
195
208
  end
196
-
197
- # # Skip is already done
198
- # return if @initialized
199
-
200
- # # Go through init if not already done
201
- # self.init
202
209
  end
203
210
 
204
211
  end
@@ -33,10 +33,11 @@ module BmcDaemonLib
33
33
 
34
34
  def logfile pipe
35
35
  # Disabled if no valid config
36
- return nil unless Conf[:logs].is_a?(Hash) && Conf.at(:logs, pipe)
36
+ #return nil unless Conf[:logs].is_a?(Hash) && Conf.at(:logs, pipe)
37
37
 
38
- # Compute logfile and check if we can write there
39
- logfile = File.expand_path(Conf[:logs][pipe].to_s, Conf[:logs][:path].to_s)
38
+ # Build logfile from Conf
39
+ logfile = Conf.logfile_path pipe
40
+ return nil if logfile.nil?
40
41
 
41
42
  # Check that we'll be able to create logfiles
42
43
  if File.exists?(logfile)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bmc-daemon-lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bruno MEDICI
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-22 00:00:00.000000000 Z
11
+ date: 2016-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler