peastash 0.2.5 → 0.2.6

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
  SHA256:
3
- metadata.gz: 3523f0e68ce08c25fb5190edc2adf0d4552e7f83fb0999bdfa2c5a0416a86f20
4
- data.tar.gz: c9be85c295ef6cac39e48af37e0b0047e8612950e8588398ca8c07d11ddbad53
3
+ metadata.gz: f7bf5afe018f224b34756bf038a5c4c09c0b798b63d492798e8a62221d873a08
4
+ data.tar.gz: 744cb15f8c32f8488daaed99f5134d8495986a999eb6bfd71cb6e978869e4019
5
5
  SHA512:
6
- metadata.gz: 8502a33c3850bcb20e78a5b23612328749f69cf65c5b337540481c5bcfc2b608d64cfa54dadb6b9b51b9959c32524db820420d8b3d172a8230693fd5e5bb8073
7
- data.tar.gz: b50c0f042e7828317aafd27705278c212a298cd827794f40977797333e9c7b9a7013d18dad8918f38edd6c3cc6a430b35798f3fcdf4cb2829b78d730a460990a
6
+ metadata.gz: cf1bec64ffc74f0acd056530b90d68e74c7e514d5b77541445bdc573bf6a8113be12ef13e447f1803d76d756a7c1a72774391a972e638b3143f0f6085a7e4f34
7
+ data.tar.gz: 99b5fe4a860fa4171db5f695454e77c5eeffbbff8e3b44e309663e85fee24a7afccce478a12dd6e82062bf528c692657bd1c75bf2f405ed2d0dfbc568daad47d
data/README.md CHANGED
@@ -69,6 +69,8 @@ If the argument is a path to a non-writeable file, Peastash will attempt to dele
69
69
  Peastash can easily be extended to output to any target.
70
70
  Simply configure Peastash's output with an object that responds to the ``#dump`` method. This method will be called at the end of the ``#log`` block, with 1 argument: a ``LogStash::Event`` object that you will probably need to serialize to json.
71
71
 
72
+ In case the directory doesn't exist, peastash won't crash, a tempfile will be created in /tmp (or $TMPDIR) and the data will be stored in this file. The full path of this tempfile will be printed to STDERR so it can easily be retrieved.
73
+
72
74
  ### What if I want to use it in my rack app?
73
75
 
74
76
  There's a middleware for that! Simply add the following somewhere:
@@ -10,6 +10,11 @@ class Peastash
10
10
  STDERR.puts "[#{Time.now}][#{Process.pid}] Could not open #{filename} for writing, recreating it. Info: #{stat_data.inspect}"
11
11
  FileUtils.rm(filename)
12
12
  create_logfile(filename)
13
+ rescue Errno::ENOENT => e
14
+ require 'tempfile'
15
+ temp_file = Tempfile.new([filename, '.log'])
16
+ STDERR.puts "[#{Time.now}][#{Process.pid}] Could not open #{filename} for writing: #{e.message}. Data will be writen in: #{temp_file.path}"
17
+ open_logfile(temp_file.path)
13
18
  end
14
19
  end
15
20
  end
@@ -10,6 +10,16 @@ class Peastash
10
10
  end
11
11
 
12
12
  def initialize(file, *args)
13
+ if file.is_a?(String)
14
+ # Rewrite symlink path to realpath for instance
15
+ # /home/app/releases/20190528155050/log/logstash.log -> /home/app/shared/log/logstash.log
16
+ # if the symlinked folder gets deleted on further releases, the log rotation will fail with
17
+ # a long wait ending with : log rotation inter-process lock failed.
18
+ # realpath is called without the filename because it expects the full path to exists
19
+ dir = File.realpath(File.dirname(file))
20
+ name = File.basename(file)
21
+ file = "#{dir}/#{name}"
22
+ end
13
23
  @device = ::Peastash::LogDevice.new(file, *args)
14
24
  end
15
25
 
@@ -1,3 +1,3 @@
1
1
  class Peastash
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: peastash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincent Boisard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-23 00:00:00.000000000 Z
11
+ date: 2019-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstash-event