Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default quiet=false when background with logfile #568

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

### Fixed
- Reporting version via `resque-scheduler --version`
- Verbosity when run in background with logfile present

## [4.3.0] - 2016-06-26
### Added
Expand Down
14 changes: 7 additions & 7 deletions lib/resque/scheduler/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,7 @@ def cleanup
def setup_backgrounding
return unless options[:background]

# Need to set this here for conditional Process.daemon redirect of
# stderr/stdout to /dev/null
Resque::Scheduler.quiet = if options.key?(:quiet)
!!options[:quiet]
else
true
end
Resque::Scheduler.quiet = background_quiet?

unless Process.respond_to?('daemon')
abort 'background option is set, which requires ruby >= 1.9'
Expand All @@ -46,6 +40,12 @@ def setup_backgrounding
Resque.redis.client.reconnect
end

def background_quiet?
return !!options[:quiet] if options.key?(:quiet)
return false if options.key?(:logfile)
!!options[:background]
end

def setup_pid_file
return unless options[:pidfile]

Expand Down
14 changes: 14 additions & 0 deletions test/env_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,18 @@ def new_env(options = {})
env.setup
assert_equal(false, Resque::Scheduler.dynamic)
end

[
[{}, true],
[{ quiet: 'nonempty' }, true],
[{ quiet: true }, true],
[{ quiet: false }, false],
[{ logfile: 'some/were.log' }, false]
].each do |opts, value|
bgopts = opts.merge(background: true)

test "sets quiet=#{value} with opts=#{bgopts.inspect}" do
assert_equal(value, new_env(bgopts).send(:background_quiet?))
end
end
end