skiplock 1.1.5 → 1.1.7

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: 251899d30b6c22a82be564d61da33bca7734fd67516eec5d6cc122ebde93ccaa
4
- data.tar.gz: fa090c287d2f3fcbe03a45a324832d4d5a1fa800e26c26deb40091789c712df5
3
+ metadata.gz: 9dc423c28696ac2e1a85e87cbc5bb97d601fbbaa14a10e58f11945863d3bd04f
4
+ data.tar.gz: 459d76ff36b464020fb43986713e744500f3f0a2fb0910ee6cec6bd082147630
5
5
  SHA512:
6
- metadata.gz: bd62845a436ea37e27da889beecec6f2b16b4d3be745c3d336da4a3a9aacf34867e586e9ecb186e816e9784969dfee754d1fccb3e0ba8dedb8d63fada1eb9304
7
- data.tar.gz: ef58e25457ac5ef98c385d122ca3252b161ddf62a589cfefb04286aaec5c2def0f52b6b334e554e8451adfe044f7be7c010a00d9c42a801731e6a7a6b3c5836d
6
+ metadata.gz: a9442d819c8eff5cb5df09a58b698dc6ce72d579971519c8947a9e7341b67617d5d1977783474b0602a12ea63a8271be9ddd0320a16062d36b9adfa077f30905
7
+ data.tar.gz: 2d5fa15b5f165c8ded5aa5fa46a2a0710b53f8379c7d4c56685d37353158f365480fce6203323f20693384deaf092d69bc03efad05f35c500ec2c4a53b7a4b09
data/README.md CHANGED
@@ -54,8 +54,10 @@ The library is quite small compared to other PostgreSQL job queues (eg. *delay_j
54
54
  min_threads: 1
55
55
  max_threads: 10
56
56
  max_retries: 20
57
- logfile: skiplock.log
58
- loglevel: info
57
+ log_file: skiplock.log
58
+ log_level: info
59
+ log_count: 5
60
+ log_size: 10485760
59
61
  namespace:
60
62
  notification: custom
61
63
  extensions: false
@@ -70,8 +72,10 @@ The library is quite small compared to other PostgreSQL job queues (eg. *delay_j
70
72
  - **min_threads** (*integer*): sets minimum number of threads staying idle
71
73
  - **max_threads** (*integer*): sets the maximum number of threads allowed to run jobs
72
74
  - **max_retries** (*integer*): sets the maximum attempt a job will be retrying before it is marked expired. See `Retry system` for more details
73
- - **logfile** (*string*): filename for skiplock logs; empty logfile will disable logging
74
- - **loglevel** (*string*): sets logging level (`debug, info, warn, error, fatal, unknown`)
75
+ - **log_file** (*string*): filename for skiplock logs; empty logfile will disable logging
76
+ - **log_level** (*string*): sets logging level (`debug, info, warn, error, fatal, unknown`)
77
+ - **log_count** (*integer*): number of log files to keep (ie: log rotation)
78
+ - **log_size** (*integer*): maximum size per log file (in bytes)
75
79
  - **namespace** (*string*): sets namespace for jobs (workers will only process jobs of specified namespace)
76
80
  - **notification** (*string*): sets the library to be used for notifying errors and exceptions (`auto, airbrake, bugsnag, exception_notification, custom`); using `auto` will detect library if available. See `Notification system` for more details
77
81
  - **extensions** (*multi*): enable or disable the class method extension. See `ClassMethod extension` for more details
data/bin/skiplock CHANGED
@@ -6,8 +6,10 @@ begin
6
6
  op = OptionParser.new do |opts|
7
7
  opts.banner = "Usage: #{File.basename($0)} [options]"
8
8
  opts.on('-e', '--environment STRING', String, 'Rails environment')
9
- opts.on('-l', '--logfile STRING', String, 'Log filename')
10
- opts.on('-L', '--loglevel STRING', String, 'Log level (debug, info, warn, error, fatal, unknown)')
9
+ opts.on('-l', '--log-file STRING', String, 'Log filename')
10
+ opts.on('-L', '--log-level STRING', String, 'Log level (debug, info, warn, error, fatal, unknown)')
11
+ opts.on('-m', '--log-count NUM', Integer, 'Log maximum count (default = 5)')
12
+ opts.on('-M', '--log-size NUM', Integer, 'Log maximum size (in bytes, default = 10485760)')
11
13
  opts.on('-n', '--namespace STRING', String, 'Job namespace')
12
14
  opts.on('-s', '--graceful-shutdown NUM', Integer, 'Number of seconds to wait for graceful shutdown')
13
15
  opts.on('-r', '--max-retries NUM', Integer, 'Number of maxixum retries')
@@ -85,8 +85,12 @@ module Skiplock
85
85
  @logger.info " Max threads: #{@config[:max_threads]}"
86
86
  @logger.info " Environment: #{Rails.env}"
87
87
  @logger.info " Namespace: #{@config[:namespace] || '(nil)'}"
88
- @logger.info " Loglevel: #{@config[:loglevel]}"
89
- @logger.info " Logfile: #{@config[:logfile] || '(disabled)'}"
88
+ @logger.info " Log level: #{@config[:log_level]}"
89
+ if @config[:log_file]
90
+ @logger.info " Log count: #{@config[:log_count]}"
91
+ @logger.info " Log size: #{@config[:log_size]}"
92
+ end
93
+ @logger.info " Log file: #{@config[:log_file] || '(disabled)'}"
90
94
  @logger.info " Workers: #{@config[:workers]}"
91
95
  @logger.info " Queues: #{@config[:queues].map {|k,v| k + '(' + v.to_s + ')'}.join(', ')}" if @config[:queues].is_a?(Hash)
92
96
  @logger.info " PID: #{Process.pid}"
@@ -140,19 +144,19 @@ module Skiplock
140
144
  end
141
145
 
142
146
  def setup_logger
143
- @config[:loglevel] = 'info' unless ['debug','info','warn','error','fatal','unknown'].include?(@config[:loglevel].to_s)
147
+ @config[:log_level] = 'info' unless ['debug','info','warn','error','fatal','unknown'].include?(@config[:log_level].to_s)
144
148
  if defined?(ActiveSupport::BroadcastLogger)
145
149
  @logger = ActiveSupport::BroadcastLogger.new(::Logger.new(STDOUT))
146
150
  else
147
151
  @logger = ActiveSupport::Logger.new(STDOUT)
148
152
  end
149
- @logger.level = @config[:loglevel].to_sym
153
+ @logger.level = @config[:log_level].to_sym
150
154
  Skiplock.logger = @logger
151
- if @config[:logfile].to_s.length > 0
155
+ if @config[:log_file].to_s.length > 0
152
156
  if defined?(ActiveSupport::BroadcastLogger)
153
- @logger.broadcast_to(::Logger.new(File.join(Rails.root, 'log', @config[:logfile].to_s), 'daily'))
157
+ @logger.broadcast_to(::Logger.new(File.join(Rails.root, 'log', @config[:log_file].to_s), @config[:log_count] || 5, @config[:log_size] || 10485760))
154
158
  else
155
- @logger.extend(ActiveSupport::Logger.broadcast(::Logger.new(File.join(Rails.root, 'log', @config[:logfile].to_s), 'daily')))
159
+ @logger.extend(ActiveSupport::Logger.broadcast(::Logger.new(File.join(Rails.root, 'log', @config[:log_file].to_s), @config[:log_count] || 5, @config[:log_size] || 10485760)))
156
160
  end
157
161
  ActiveJob::Base.logger = nil
158
162
  end
@@ -1,4 +1,3 @@
1
1
  module Skiplock
2
- VERSION = Version = '1.1.5'
2
+ VERSION = Version = '1.1.7'
3
3
  end
4
-
data/lib/skiplock.rb CHANGED
@@ -11,7 +11,7 @@ require 'skiplock/worker'
11
11
  require 'skiplock/version'
12
12
 
13
13
  module Skiplock
14
- DEFAULT_CONFIG = { 'graceful_shutdown' => 15, 'min_threads' => 1, 'max_threads' => 10, 'max_retries' => 20, 'logfile' => 'skiplock.log', 'loglevel' => 'info', 'namespace' => nil, 'notification' => 'custom', 'extensions' => false, 'purge_completion' => true, 'queues' => { 'default' => 100, 'mailers' => 999 }, 'workers' => 0 }.freeze
14
+ DEFAULT_CONFIG = { 'graceful_shutdown' => 15, 'min_threads' => 1, 'max_threads' => 10, 'max_retries' => 20, 'log_file' => 'skiplock.log', 'log_level' => 'info', 'log_count' => 5, 'log_size' => 10485760, 'namespace' => nil, 'notification' => 'custom', 'extensions' => false, 'purge_completion' => true, 'queues' => { 'default' => 100, 'mailers' => 999 }, 'workers' => 0 }.freeze
15
15
 
16
16
  def self.logger=(l)
17
17
  @logger = l
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skiplock
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tin Vo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-12 00:00:00.000000000 Z
11
+ date: 2024-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activejob