Skip to content

Commit 1bdd41e

Browse files
scotttamdefunkt
authored andcommitted
renamed before_fork to before_first_fork.
1 parent 6026def commit 1bdd41e

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

lib/resque.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ def redis
4949
end
5050

5151
#Set a proc that will be called once before the worker forks
52-
def before_fork=(before_fork)
53-
@before_fork = before_fork
52+
def before_first_fork=(before_first_fork)
53+
@before_first_fork = before_first_fork
5454
end
5555

56-
#Returns the before_fork proc
57-
def before_fork
58-
@before_fork
56+
#Returns the before_first_fork proc
57+
def before_first_fork
58+
@before_first_fork
5959
end
6060

6161
#Set a proc that will be called after the worker forks

lib/resque/helpers.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ def redis
66
Resque.redis
77
end
88

9-
#Direct access to the before_fork proc
10-
def before_fork
11-
Resque.before_fork
9+
#Direct access to the before_first_fork proc
10+
def before_first_fork
11+
Resque.before_first_fork
1212
end
1313

1414
#Direct access to the after_fork proc

lib/resque/worker.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def startup
203203
enable_gc_optimizations
204204
register_signal_handlers
205205
prune_dead_workers
206-
call_before_fork
206+
call_before_first_fork
207207
register_worker
208208
end
209209

@@ -308,14 +308,14 @@ def register_worker
308308
started!
309309
end
310310

311-
#Call any before_fork procs, if any
312-
def call_before_fork
313-
return unless before_fork
314-
log "Calling before_fork"
315-
before_fork.call
311+
#Call any before_first_fork procs, if any
312+
def call_before_first_fork
313+
return unless before_first_fork
314+
log "Calling before_first_fork"
315+
before_first_fork.call
316316
end
317317

318-
#Call any before_fork procs, if any
318+
#Call any before_first_fork procs, if any
319319
def call_after_fork
320320
return unless after_fork
321321
log "Calling after_fork"

test/worker_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,14 +244,14 @@
244244
test "Will call a before_fork proc when the worker starts if set in the initializer only once" do
245245
Resque.redis.flush_all
246246
$BEFORE_FORK_CALLED = false
247-
Resque.before_fork = Proc.new { $BEFORE_FORK_CALLED = true }
247+
Resque.before_first_fork = Proc.new { $BEFORE_FORK_CALLED = true }
248248
workerA = Resque::Worker.new(:jobs)
249249
Resque::Job.create(:jobs, SomeJob, 20, '/tmp')
250250

251251
assert !$BEFORE_FORK_CALLED
252252
workerA.work(0)
253253
assert $BEFORE_FORK_CALLED
254-
Resque.before_fork = nil
254+
Resque.before_first_fork = nil
255255
end
256256

257257
test "Will call a after_fork proc after the worker has successfully forked" do

0 commit comments

Comments
 (0)