skylight 1.0.0 → 1.0.1

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: 28dd7214b4627640a19b45a6e5fc331fbfacf27c
4
- data.tar.gz: 024db5832f07bc150605be92ab4e08dd564d5e17
3
+ metadata.gz: 9d299c38749f9eb46bf2ed780d3b554760d8728b
4
+ data.tar.gz: 74e57f72bc4bc58ab4a8977382d930e032414ca4
5
5
  SHA512:
6
- metadata.gz: e061ebe3cb082688bf4b1986aa48bd6cb9ed3810097f1eced4f0c96c589d53eb3072c394fa163c5d792ce8c271efb9202931f02b68f325c8d36d19ce4f2e283e
7
- data.tar.gz: 51def9a798e16514df5de9eecb62ad70ed78d00770837ef73c81805a5b6b6d948c707cecd6011515eb9b6f8fa3d61b7a052394b8134938515315478a445c9ebf
6
+ metadata.gz: b4d63a7ac26843af364e798327841652ee2a9fc21b0724845190f0a7e963886ab534fc16a813ab673dab32f37cc59835c7f459255881594542c6827d7eeac190
7
+ data.tar.gz: 70b05635d94f0b60ede936c2b645c978497fcb85fb8acc061290124b595bff1849367b9977bc618513cd26e985700723355dc38b569468a4ad8afd532ded0456
@@ -1,3 +1,9 @@
1
+ ## 1.0.1 (November 15, 2016)
2
+
3
+ * [BUGFIX] Gracefully handle non-writable log files
4
+ * [BUGFIX] Fix skylight doctor's handling of config files
5
+ * [BUGFIX] Support MetalControllers that don't use ActionController::Rendering
6
+
1
7
  ## 1.0.0 (October 19, 2016)
2
8
 
3
9
  * [BETA FEATURE] Track separate segments for endpoints. Contact support@skylight.io to have this feature enabled for your account.
@@ -1,6 +1,6 @@
1
1
  ---
2
- version: "1.0.0-4a74d28"
2
+ version: "1.0.1-fcb0e55"
3
3
  checksums:
4
- x86-linux: "66e1b9fd8c9223febf8e7febb56a2ad71714ab61193d153e2bf0f462409cb4f7"
5
- x86_64-linux: "40d7e0822610244d916df5488a83af5bdc7b2aa8b2410abc672a42cfab629f3f"
6
- x86_64-darwin: "1484612b150317f1debdcaeab9bea806749d8be9ac132b8cd1b92781d1972b46"
4
+ x86-linux: "8a4b585dc72735947bc3bd7ae24c11e92dbe8d57af4afb7345df561fad563804"
5
+ x86_64-linux: "7c192d9c98715f32be74c20596738e48af295629a401dffe5aff21da796231ed"
6
+ x86_64-darwin: "8bd31a89a7bdb32c0903608c5e73818af9dfb0f8b3f3004ec2fa8f587ee5f819"
@@ -14,7 +14,7 @@ module Skylight
14
14
 
15
15
  # Normally auto-loaded, but we haven't loaded Rails by the time Skylight is loaded
16
16
  require 'skylight/railtie'
17
- require File.expand_path('config/application', Dir.pwd)
17
+ require rails_rb
18
18
  else
19
19
  say "No Rails application detected", :red
20
20
  abort "Currently `skylight doctor` only works with Rails applications"
@@ -54,10 +54,6 @@ module Skylight
54
54
  def check_config
55
55
  say "Checking for valid configuration"
56
56
 
57
- # MEGAHAX
58
- railtie = Skylight::Railtie.send(:new)
59
- config = railtie.send(:load_skylight_config, Rails.application)
60
-
61
57
  indent do
62
58
  begin
63
59
  config.validate!
@@ -127,6 +123,17 @@ module Skylight
127
123
  def status
128
124
  say "All checks passed!", :green
129
125
  end
126
+
127
+ private
128
+
129
+ # Overwrite the default helper method to load from Rails
130
+ def config
131
+ return @config if @config
132
+
133
+ # MEGAHAX
134
+ railtie = Skylight::Railtie.send(:new)
135
+ @config = railtie.send(:load_skylight_config, Rails.application)
136
+ end
130
137
  end
131
138
  end
132
139
  end
@@ -296,10 +296,15 @@ module Skylight
296
296
  # TODO: Move this out of the validate! method: https://github.com/tildeio/direwolf-agent/issues/273
297
297
  # FIXME: Why not set the sockdir_path and pidfile_path explicitly?
298
298
  # That way we don't have to keep this in sync with the Rust repo.
299
- sockdir_path = self[:'daemon.sockdir_path'] || File.expand_path('.')
300
- pidfile_path = self[:'daemon.pidfile_path'] || File.expand_path('skylight.pid', sockdir_path)
299
+ sockdir_path = File.expand_path(self[:'daemon.sockdir_path'] || '.', root)
300
+ pidfile_path = File.expand_path(self[:'daemon.pidfile_path'] || 'skylight.pid', sockdir_path)
301
+ log_file = self[:log_file]
302
+ alert_log_file = self[:alert_log_file]
301
303
 
302
- check_permissions(pidfile_path, sockdir_path)
304
+ check_file_permissions(pidfile_path, "daemon.pidfile_path or daemon.sockdir_path")
305
+ check_sockdir_permissions(sockdir_path)
306
+ check_logfile_permissions(log_file, "log_file")
307
+ check_logfile_permissions(alert_log_file, "alert_log_file")
303
308
 
304
309
  true
305
310
  end
@@ -348,31 +353,40 @@ module Skylight
348
353
  return true
349
354
  end
350
355
 
351
- def check_permissions(pidfile, sockdir_path)
352
- pidfile_root = File.dirname(pidfile)
356
+ def check_file_permissions(file, key)
357
+ file_root = File.dirname(file)
353
358
 
354
- FileUtils.mkdir_p pidfile_root
355
- FileUtils.mkdir_p sockdir_path
359
+ # Try to make the directory, don't blow up if we can't. Our writable? check will fail later.
360
+ FileUtils.mkdir_p file_root rescue nil
356
361
 
357
- if File.exist?(pidfile)
358
- unless FileTest.writable?(pidfile)
359
- raise ConfigError, "File `#{pidfile}` not writable. Please set daemon.pidfile_path or daemon.sockdir_path in your config to a writable path"
360
- end
361
- else
362
- unless FileTest.writable?(pidfile_root)
363
- raise ConfigError, "Directory `#{pidfile_root}` not writable. Please set daemon.pidfile_path or daemon.sockdir_path in your config to a writable path"
364
- end
362
+ if File.exist?(file) && !FileTest.writable?(file)
363
+ raise ConfigError, "File `#{file}` is not writable. Please set #{key} in your config to a writable path"
364
+ end
365
+
366
+ unless FileTest.writable?(file_root)
367
+ raise ConfigError, "Directory `#{file_root}` is not writable. Please set #{key} in your config to a writable path"
365
368
  end
369
+ end
370
+
371
+ def check_sockdir_permissions(sockdir_path)
372
+ # Try to make the directory, don't blow up if we can't. Our writable? check will fail later.
373
+ FileUtils.mkdir_p sockdir_path rescue nil
366
374
 
367
375
  unless FileTest.writable?(sockdir_path)
368
- raise ConfigError, "Directory `#{sockdir_path}` not writable. Please set daemon.sockdir_path in your config to a writable path"
376
+ raise ConfigError, "Directory `#{sockdir_path}` is not writable. Please set daemon.sockdir_path in your config to a writable path"
369
377
  end
370
378
 
371
- if check_nfs(pidfile)
379
+ if check_nfs(sockdir_path)
372
380
  raise ConfigError, "Directory `#{sockdir_path}` is an NFS mount and will not allow sockets. Please set daemon.sockdir_path in your config to a non-NFS path."
373
381
  end
374
382
  end
375
383
 
384
+ def check_logfile_permissions(log_file, key)
385
+ return if log_file == '-' # STDOUT
386
+ log_file = File.expand_path(log_file, root)
387
+ check_file_permissions(log_file, key)
388
+ end
389
+
376
390
  def key?(key)
377
391
  key = Config.remap_key(key)
378
392
  @priority.key?(key) || @values.key?(key)
@@ -556,26 +570,17 @@ authentication: #{self[:authentication]}
556
570
  end
557
571
 
558
572
  def alert_logger
559
- @alert_logger ||=
560
- begin
561
- MUTEX.synchronize do
562
- unless l = @alert_logger
563
- out = get(:alert_log_file)
564
-
565
- if out == '-'
566
- out = Util::AlertLogger.new(load_logger)
567
- elsif !(IO === out)
568
- out = File.expand_path(out, root)
569
- FileUtils.mkdir_p(File.dirname(out))
570
- end
571
-
572
- l = Logger.new(out)
573
- l.level = Logger::DEBUG
574
- end
573
+ @alert_logger ||= MUTEX.synchronize do
574
+ unless l = @alert_logger
575
+ out = get(:alert_log_file)
576
+ out = Util::AlertLogger.new(load_logger) if out == '-'
575
577
 
576
- l
577
- end
578
+ l = create_logger(out)
579
+ l.level = Logger::DEBUG
578
580
  end
581
+
582
+ l
583
+ end
579
584
  end
580
585
 
581
586
  def alert_logger=(logger)
@@ -601,17 +606,24 @@ authentication: #{self[:authentication]}
601
606
  `stat -f -L -c %T #{path} 2>&1`.strip == 'nfs'
602
607
  end
603
608
 
609
+ def create_logger(out)
610
+ if out.is_a?(String)
611
+ out = File.expand_path(out, root)
612
+ # May be redundant since we also do this in the permissions check
613
+ FileUtils.mkdir_p(File.dirname(out))
614
+ end
615
+
616
+ Logger.new(out)
617
+ rescue
618
+ Logger.new(STDOUT)
619
+ end
620
+
604
621
  def load_logger
605
622
  unless l = @logger
606
623
  out = get(:log_file)
607
624
  out = STDOUT if out == '-'
608
625
 
609
- unless IO === out
610
- out = File.expand_path(out, root)
611
- FileUtils.mkdir_p(File.dirname(out))
612
- end
613
-
614
- l = Logger.new(out)
626
+ l = create_logger(out)
615
627
  l.level =
616
628
  case get(:log_level)
617
629
  when /^debug$/i then Logger::DEBUG
@@ -10,7 +10,7 @@ module Skylight
10
10
  append_info_to_payload_without_sk(payload)
11
11
  if respond_to?(:rendered_format)
12
12
  rendered_mime = rendered_format
13
- else
13
+ elsif respond_to?(:lookup_context)
14
14
  format = lookup_context.formats.first
15
15
  rendered_mime = Mime[format.to_sym] if format
16
16
  end
@@ -1,4 +1,4 @@
1
1
  module Skylight
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
4
4
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skylight
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tilde, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-19 00:00:00.000000000 Z
11
+ date: 2016-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport