Skip to content

Commit

Permalink
Adds support for running as a forking process in the foreground
Browse files Browse the repository at this point in the history
Reason: The `script/delayed_job` process (described above) uses the
[Daemons](https://github.com/thuehlinger/daemons) gem which has several
undesirable behaviors when running inside a container (Docker, etc.):
- The parent process spawns a background child process then exits immediately,
which causes the container to shutdown.
- The worker processes are detached from the parent, which prevents logging to `STDOUT`.

The `--fork` option solves this by running workers in a foreground process tree.
When using `--fork` the `daemons` gem is not required.

The command script requires changing the following line to enable this:

# always daemonizes, never forks
Delayed::Command.new(ARGV).daemonize

must now be:

# daemonize by default unless --fork specified
Delayed::Command.new(ARGV).launch

In addition, there are several quality of life improvements added to the Command script:
- Command: Add --pools arg as an alias for --pool, and allow pipe-delimited pool definitions
- Command: Add --num-worker arg as an alias for -n / --number-of-workers (and deprecate --number-of-workers)
- Command: Pool parsing code has been extracted to PoolParser class
- Command: Add -v / --verbose switch which sets quiet=false on workers
- Command: Add -x switch as alias for --exit-on-complete
- Command: Add STDERR warning num-workers less than 1
- Command: Add STDERR warning if num-workers and pools both specified (pools overrides num-workers as per existing behavior)
- Command: Add STDERR warning if queues and pools both specified (pools overrides num-workers as per existing behavior)

The Rake script has also been enhanced:
- Rake: Uses Forking launcher under the hood
- Rake: Add support for NUM_WORKERS and POOLS args
  • Loading branch information
johnnyshields committed Apr 4, 2021
1 parent baed6e8 commit 54eba86
Show file tree
Hide file tree
Showing 18 changed files with 1,243 additions and 383 deletions.
61 changes: 40 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,51 @@ on:
jobs:
test:
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
ruby: [2.5, 2.6, 2.7, jruby, jruby-head, ruby-head]
ruby:
- '2.5'
- '2.6'
- '2.7'
- '3.0'
- 'jruby'
rails_version:
- '5.2.0'
- '6.0.0'
- '6.1.0.rc2'
- 'edge'
- '6.0'
- '6.1'
include:
#
# The past
#
# EOL Active Record
- ruby: 2.2
rails_version: '3.2.0'
- ruby: 2.1
rails_version: '4.1.0'
- ruby: 2.4
rails_version: '4.2.0'
- ruby: 2.4
rails_version: '5.0.0'
- ruby: 2.5
rails_version: '5.1.0'

continue-on-error: ${{ matrix.rails_version == 'edge' || endsWith(matrix.ruby, 'head') }}
# Older Rails
- ruby: '2.2'
rails_version: '3.2'
- ruby: '2.1'
rails_version: '4.1'
- ruby: '2.4'
rails_version: '4.2'
- ruby: '2.4'
rails_version: '5.0'
- ruby: '2.5'
rails_version: '5.1'
- ruby: '2.5'
rails_version: '5.2'
- ruby: 'jruby'
rails_version: '5.2'
# Experimental
- ruby: 'ruby-head'
rails_version: '6.1'
experimental: true
- ruby: 'jruby-head'
rails_version: '6.1'
experimental: true
- ruby: '2.7'
rails_version: 'edge'
experimental: true
- ruby: '3.0'
rails_version: 'edge'
experimental: true
- ruby: 'jruby'
rails_version: 'edge'
experimental: true

steps:
- uses: actions/checkout@v2
Expand Down
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ SignalException:
SpaceInsideHashLiteralBraces:
EnforcedStyle: no_space

Style/SpecialGlobalVars:
Enabled: false

Style/SymbolArray:
Enabled: false

Expand Down
Loading

0 comments on commit 54eba86

Please sign in to comment.