workhorse 1.2.7 → 1.2.9

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: 36904c2ff67ab30f876e47515dfd81ccb97715a6e3d563ba93bd59422374d660
4
- data.tar.gz: 0c9c66eb75727e78fc842e1a30de12876da67a571aa255855e3ae1e63c27f847
3
+ metadata.gz: 2e55e6209a84d648692e6aa3a883ff1536282525b2d5dd779c77614809459fb8
4
+ data.tar.gz: '05593223d445e9999f605464974a487611c6e6883f290b492038076e33ef86f3'
5
5
  SHA512:
6
- metadata.gz: 0d57c98c31ad7c25f4ad267fe3caa21ae831e986579fef5f2f848c21a7977c0790b461e3372d4cff5e8e89efdb7a0774f06a90542bf0fb4c87baabe8c472ad06
7
- data.tar.gz: c99c9d68c24dcccf1bdd164c066466a9c68fa94c7f66dbdc14986dc841e99c0361e32d53a0e2a85226de9c3580ea295254e2c4cb49cd53e974fc28150d3c6e0b
6
+ metadata.gz: c3a3eea6bfcbff533c9c98c2b9f0750eb1088ec2b616d801ac90c12c3a6afd5010fa7f4eac64df9a728b5fb92d5d43c4bb983708e32f0b6fa01bba1cf0ced5e9
7
+ data.tar.gz: 0b357f5d1abe994f46b9ea2736d9cf613ea26c137f5814c7268bb33794f665cd63c90e1e8ed3a52c868582cb8b5117cd2f524299ab693a151deb4ccb0ef34015
data/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # Workhorse Changelog
2
2
 
3
+ ## 1.2.9 - 2022-12-08
4
+
5
+ * Properly detach forked worker processes from parent process to prevent zombie
6
+ processes
7
+
8
+ * Reopen STDIN, STDOUT and STDERR pipes to `/dev/null` after forking
9
+ (daemonizing) worker processes. This detaches from the current TTY which
10
+ prevents the issue that SSH connections sometimes could not be closed when
11
+ having daemonized new worker processes.
12
+
13
+ Sitrox reference: #107576.
14
+
15
+ ## 1.2.8 - 2022-11-23
16
+
17
+ * Add configuration option `lock_shell_commands`. This defaults to `true` to
18
+ retain backwards compatibility and allows turning off file locking for shell
19
+ commands (e.g. for cases where the locking is done outside of workhorse like
20
+ in a wrapper script).
21
+
22
+ Sitrox reference: #106900.
23
+
3
24
  ## 1.2.7 - 2022-04-07
4
25
 
5
26
  * Adapt exit status of shell handler to return with exit code `2` when a worker
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.7
1
+ 1.2.9
@@ -12,6 +12,10 @@ Workhorse.setup do |config|
12
12
  # ActiveRecord::Base.transaction(*args, &block)
13
13
  # end
14
14
 
15
+ # Set this to false in order to disable file-based locking for the Workhorse
16
+ # shell handlers (all the commands such as 'start', 'stop', ...).
17
+ # config.lock_shell_commands = true
18
+
15
19
  # Enable and configure this to specify a callback for handling worker
16
20
  # exceptions:
17
21
  #
@@ -6,9 +6,13 @@ module Workhorse
6
6
  exit 99
7
7
  end
8
8
 
9
- lockfile_path = options.delete(:lockfile) || 'workhorse.lock'
10
- lockfile = File.open(lockfile_path, 'a')
11
- lockfile.flock(File::LOCK_EX || File::LOCK_NB)
9
+ if Workhorse.lock_shell_commands
10
+ lockfile_path = options.delete(:lockfile) || 'workhorse.lock'
11
+ lockfile = File.open(lockfile_path, 'a')
12
+ lockfile.flock(File::LOCK_EX || File::LOCK_NB)
13
+ else
14
+ lockfile = nil
15
+ end
12
16
 
13
17
  daemon = Workhorse::Daemon.new(**options, &block)
14
18
 
@@ -40,7 +44,7 @@ module Workhorse
40
44
  warn "#{e.message}\n#{e.backtrace.join("\n")}"
41
45
  exit 99
42
46
  ensure
43
- lockfile.flock(File::LOCK_UN)
47
+ lockfile&.flock(File::LOCK_UN)
44
48
  end
45
49
  end
46
50
 
@@ -147,9 +147,17 @@ module Workhorse
147
147
  def start_worker(worker)
148
148
  pid = fork do
149
149
  $0 = process_name(worker)
150
+
151
+ # Reopen pipes to prevent #107576
152
+ STDIN.reopen File.open('/dev/null', 'r')
153
+ null_out = File.open '/dev/null', 'w'
154
+ STDOUT.reopen null_out
155
+ STDERR.reopen null_out
156
+
150
157
  worker.block.call
151
158
  end
152
159
  IO.write(pid_file_for(worker), pid)
160
+ Process.detach(pid)
153
161
  end
154
162
 
155
163
  def stop_worker(pid_file, pid, kill = false)
data/lib/workhorse.rb CHANGED
@@ -31,6 +31,12 @@ module Workhorse
31
31
  # ExceptionNotifier.notify_exception(exception)
32
32
  end
33
33
 
34
+ # If set to `false`, shell handler (CLI) won't lock commands using a lockfile.
35
+ # You should generally only disable this if you are performing the locking
36
+ # yourself (e.g. in a wrapper script).
37
+ mattr_accessor :lock_shell_commands
38
+ self.lock_shell_commands = true
39
+
34
40
  # If set to `true`, the defined `on_exception` will not be called when the
35
41
  # poller encounters an exception and the worker has to be shut down. The
36
42
  # exception will still be logged.
data/workhorse.gemspec CHANGED
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: workhorse 1.2.7 ruby lib
2
+ # stub: workhorse 1.2.9 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "workhorse".freeze
6
- s.version = "1.2.7"
6
+ s.version = "1.2.9"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
10
10
  s.authors = ["Sitrox".freeze]
11
- s.date = "2022-04-07"
11
+ s.date = "2022-12-08"
12
12
  s.files = [".github/workflows/ruby.yml".freeze, ".gitignore".freeze, ".releaser_config".freeze, ".rubocop.yml".freeze, "CHANGELOG.md".freeze, "FAQ.md".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "RUBY_VERSION".freeze, "Rakefile".freeze, "VERSION".freeze, "bin/rubocop".freeze, "lib/active_job/queue_adapters/workhorse_adapter.rb".freeze, "lib/generators/workhorse/install_generator.rb".freeze, "lib/generators/workhorse/templates/bin/workhorse.rb".freeze, "lib/generators/workhorse/templates/config/initializers/workhorse.rb".freeze, "lib/generators/workhorse/templates/create_table_jobs.rb".freeze, "lib/workhorse.rb".freeze, "lib/workhorse/daemon.rb".freeze, "lib/workhorse/daemon/shell_handler.rb".freeze, "lib/workhorse/db_job.rb".freeze, "lib/workhorse/enqueuer.rb".freeze, "lib/workhorse/jobs/cleanup_succeeded_jobs.rb".freeze, "lib/workhorse/jobs/detect_stale_jobs_job.rb".freeze, "lib/workhorse/jobs/run_active_job.rb".freeze, "lib/workhorse/jobs/run_rails_op.rb".freeze, "lib/workhorse/performer.rb".freeze, "lib/workhorse/poller.rb".freeze, "lib/workhorse/pool.rb".freeze, "lib/workhorse/scoped_env.rb".freeze, "lib/workhorse/worker.rb".freeze, "test/active_job/queue_adapters/workhorse_adapter_test.rb".freeze, "test/lib/db_schema.rb".freeze, "test/lib/jobs.rb".freeze, "test/lib/test_helper.rb".freeze, "test/workhorse/db_job_test.rb".freeze, "test/workhorse/enqueuer_test.rb".freeze, "test/workhorse/performer_test.rb".freeze, "test/workhorse/poller_test.rb".freeze, "test/workhorse/pool_test.rb".freeze, "test/workhorse/worker_test.rb".freeze, "workhorse.gemspec".freeze]
13
13
  s.rubygems_version = "3.0.3".freeze
14
14
  s.summary = "Multi-threaded job backend with database queuing for ruby.".freeze
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: workhorse
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.7
4
+ version: 1.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sitrox
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-07 00:00:00.000000000 Z
11
+ date: 2022-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -178,8 +178,8 @@ dependencies:
178
178
  - - ">="
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
- description:
182
- email:
181
+ description:
182
+ email:
183
183
  executables: []
184
184
  extensions: []
185
185
  extra_rdoc_files: []
@@ -227,10 +227,10 @@ files:
227
227
  - test/workhorse/pool_test.rb
228
228
  - test/workhorse/worker_test.rb
229
229
  - workhorse.gemspec
230
- homepage:
230
+ homepage:
231
231
  licenses: []
232
232
  metadata: {}
233
- post_install_message:
233
+ post_install_message:
234
234
  rdoc_options: []
235
235
  require_paths:
236
236
  - lib
@@ -245,8 +245,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
245
245
  - !ruby/object:Gem::Version
246
246
  version: '0'
247
247
  requirements: []
248
- rubygems_version: 3.0.3.1
249
- signing_key:
248
+ rubygems_version: 3.3.11
249
+ signing_key:
250
250
  specification_version: 4
251
251
  summary: Multi-threaded job backend with database queuing for ruby.
252
252
  test_files: