File tree Expand file tree Collapse file tree 1 file changed +24
-3
lines changed Expand file tree Collapse file tree 1 file changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -648,11 +648,32 @@ this way we can tell our Sinatra app about the config file:
648
648
649
649
Now everyone is on the same page.
650
650
651
- If you wish to have a Proc called before the worker forks for the first time, you
652
- can add it in the initializer like so:
651
+ If you wish to have a Proc called before the worker forks for the
652
+ first time, you can add it in the initializer like so:
653
653
654
- Resque.before_fork = Proc.new { puts "CALL ME ONCE BEFORE THE WORKER FORKS THE FIRST TIME" }
654
+ Resque.before_first_fork do
655
+ puts "CALL ME ONCE BEFORE THE WORKER FORKS THE FIRST TIME"
656
+ end
657
+
658
+ You can also run a hook before _ every_ fork:
659
+
660
+ Resque.before_fork do |job|
661
+ puts "CALL ME ONCE BEFORE THE WORKER FORKS THE FIRST TIME"
662
+ end
663
+
664
+ The ` before_fork ` hook will be run in the ** parent** process. So, be
665
+ careful - any changes you make will be permanent for the lifespan of
666
+ the worker.
667
+
668
+ And after forking:
669
+
670
+ Resque.after_fork do |job|
671
+ puts "CALL ME ONCE BEFORE THE WORKER FORKS THE FIRST TIME"
672
+ end
655
673
674
+ The ` after_fork ` hook will be run in the child process and is passed
675
+ the current job. Any changes you make, therefor, will only live as
676
+ long as the job currently being processes.
656
677
657
678
Namespaces
658
679
----------
You can’t perform that action at this time.
0 commit comments