Skip to content

Commit 021056d

Browse files
committed
opts: --no-pidfile overrides --pidfile
1 parent 1f409a4 commit 021056d

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

lib/resque/pool/cli.rb

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,14 @@ def parse_options(argv=nil)
4141
opt.on('-o', '--stdout FILE', "Redirect stdout to logfile") { |c| opts[:stdout] = c }
4242
opt.on('-e', '--stderr FILE', "Redirect stderr to logfile") { |c| opts[:stderr] = c }
4343
opt.on('--nosync', "Don't sync logfiles on every write") { opts[:nosync] = true }
44-
opt.on("-p", '--pidfile FILE', "PID file location") { |c| opts[:pidfile] = c }
45-
opt.on('--no-pidfile', "Force no pidfile, even if daemonized") { opts[:no_pidfile] = true }
44+
opt.on("-p", '--pidfile FILE', "PID file location") { |c|
45+
opts[:pidfile] = c
46+
opts[:no_pidfile] = false
47+
}
48+
opt.on('--no-pidfile', "Force no pidfile, even if daemonized") {
49+
opts[:pidfile] = nil
50+
opts[:no_pidfile] = true
51+
}
4652
opt.on('-l', '--lock FILE' "Open a shared lock on a file") { |c| opts[:lock_file] = c }
4753
opt.on("-E", '--environment ENVIRONMENT', "Set RAILS_ENV/RACK_ENV/RESQUE_ENV") { |c| opts[:environment] = c }
4854
opt.on("-s", '--spawn-delay MS', Integer, "Delay in milliseconds between spawning missing workers") { |c| opts[:spawn_delay] = c }
@@ -54,9 +60,6 @@ def parse_options(argv=nil)
5460
opt.on("-v", "--version", "Show Version"){ puts "resque-pool #{VERSION} (c) nicholas a. evans"; exit}
5561
end
5662
parser.parse!(argv || parser.default_argv)
57-
if opts[:pidfile]
58-
opts.delete(:no_pidfile)
59-
end
6063
if opts[:daemon]
6164
opts[:stdout] ||= "log/resque-pool.stdout.log"
6265
opts[:stderr] ||= "log/resque-pool.stderr.log"

spec/cli_spec.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,17 @@
4242
options[:pidfile].should be_nil
4343
end
4444

45-
it "--no-pidfile does not prevent explicit --pidfile setting" do
45+
it "`--no-pidfile` does not prevent explicit `--pidfile` setting" do
4646
options = cli.parse_options(%w[--no-pidfile --pidfile my.pid])
4747
options[:pidfile].should == "my.pid"
4848
options[:no_pidfile].should be_falsey
4949
end
50+
51+
it "`--no-pidfile` overrides `--pidfile`" do
52+
options = cli.parse_options(%w[--pidfile my.pid --no-pidfile])
53+
options[:pidfile].should be_nil
54+
options[:no_pidfile].should be_truthy
55+
end
56+
5057
end
5158
end

0 commit comments

Comments
 (0)