File tree Expand file tree Collapse file tree 4 files changed +17
-17
lines changed Expand file tree Collapse file tree 4 files changed +17
-17
lines changed Original file line number Diff line number Diff line change @@ -49,13 +49,13 @@ def redis
49
49
end
50
50
51
51
#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
54
54
end
55
55
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
59
59
end
60
60
61
61
#Set a proc that will be called after the worker forks
Original file line number Diff line number Diff line change @@ -6,9 +6,9 @@ def redis
6
6
Resque . redis
7
7
end
8
8
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
12
12
end
13
13
14
14
#Direct access to the after_fork proc
Original file line number Diff line number Diff line change @@ -203,7 +203,7 @@ def startup
203
203
enable_gc_optimizations
204
204
register_signal_handlers
205
205
prune_dead_workers
206
- call_before_fork
206
+ call_before_first_fork
207
207
register_worker
208
208
end
209
209
@@ -308,14 +308,14 @@ def register_worker
308
308
started!
309
309
end
310
310
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
316
316
end
317
317
318
- #Call any before_fork procs, if any
318
+ #Call any before_first_fork procs, if any
319
319
def call_after_fork
320
320
return unless after_fork
321
321
log "Calling after_fork"
Original file line number Diff line number Diff line change 244
244
test "Will call a before_fork proc when the worker starts if set in the initializer only once" do
245
245
Resque . redis . flush_all
246
246
$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 }
248
248
workerA = Resque ::Worker . new ( :jobs )
249
249
Resque ::Job . create ( :jobs , SomeJob , 20 , '/tmp' )
250
250
251
251
assert !$BEFORE_FORK_CALLED
252
252
workerA . work ( 0 )
253
253
assert $BEFORE_FORK_CALLED
254
- Resque . before_fork = nil
254
+ Resque . before_first_fork = nil
255
255
end
256
256
257
257
test "Will call a after_fork proc after the worker has successfully forked" do
You can’t perform that action at this time.
0 commit comments