@@ -48,24 +48,51 @@ def redis
48
48
self . redis
49
49
end
50
50
51
- #Set a proc that will be called once before the worker forks
51
+ # The `before_first_fork` hook will be run in the **parent** process
52
+ # only once, before forking to run the first job. Be careful- any
53
+ # changes you make will be permanent for the lifespan of the
54
+ # worker.
55
+ #
56
+ # Call with a block to set the hook.
57
+ # Call with no arguments to return the hook.
58
+ def before_first_fork ( &block )
59
+ block ? ( @before_first_fork = block ) : @before_first_fork
60
+ end
61
+
62
+ # Set a proc that will be called in the parent process before the
63
+ # worker forks for the first time.
52
64
def before_first_fork = ( before_first_fork )
53
65
@before_first_fork = before_first_fork
54
66
end
55
67
56
- #Returns the before_first_fork proc
57
- def before_first_fork
58
- @before_first_fork
68
+ # The `before_fork` hook will be run in the **parent** process
69
+ # before every job, so be careful- any changes you make will be
70
+ # permanent for the lifespan of the worker.
71
+ #
72
+ # Call with a block to set the hook.
73
+ # Call with no arguments to return the hook.
74
+ def before_fork ( &block )
75
+ block ? ( @before_fork = block ) : @before_fork
59
76
end
60
77
61
- #Set a proc that will be called after the worker forks
62
- def after_fork = ( after_fork )
63
- @after_fork = after_fork
78
+ # Set the before_fork proc.
79
+ def before_fork = ( before_fork )
80
+ @before_fork = before_fork
64
81
end
65
82
66
- #Returns the after_fork proc
67
- def after_fork
68
- @after_fork
83
+ # The `after_fork` hook will be run in the child process and is passed
84
+ # the current job. Any changes you make, therefor, will only live as
85
+ # long as the job currently being processes.
86
+ #
87
+ # Call with a block to set the hook.
88
+ # Call with no arguments to return the hook.
89
+ def after_fork ( &block )
90
+ block ? ( @after_fork = block ) : @after_fork
91
+ end
92
+
93
+ # Set the after_fork proc.
94
+ def after_fork = ( after_fork )
95
+ @after_fork = after_fork
69
96
end
70
97
71
98
def to_s
0 commit comments