How to determine the master hook?

46 views
Skip to first unread message

Victor Powell

unread,
Jul 8, 2012, 5:15:31 PM7/8/12
to hoo...@googlegroups.com

Is there a way to determine if a hook is a master hook? Or possibly detect if a hook was previously not master, and now is?

- Victor

darinc

unread,
Jul 9, 2012, 7:02:46 AM7/9/12
to hoo...@googlegroups.com
Victor,

Without knowing the exact answer, I can steer you in the right direction.  I spun up three processes each running hook --autoheal --repl, they came online as the-hook, the-hook-1 and the-hook-2.  While in the repl, you get tab complete.  So type "hook." then hit tab and you will see a list of options.  If you run hook.proposedRank on all three you will see the hooks report 0, 1, and 2 respectively as their proposed rank.  The hook with the rank of 0 is always master hook.

The other key thing with the repl is that you can see the events that fire when you disconnect the current master.  I created the following gist with the log actions for all three hooks as I killed the master hook.  https://gist.github.com/3075827

Aside from the hook.proposedRank you can see some events that fire that would be worth listening for:  hook::rank::accepting seems to report null if you are the master, or an integer greater than 0 if you are in line.

Let the group know how you solve your question.
Thanks,
<>Darin

Victor Powell

unread,
Jul 9, 2012, 9:44:58 AM7/9/12
to hoo...@googlegroups.com
Thanks for the help. Here's the solution I came up with: https://gist.github.com/3076653
Reply all
Reply to author
Forward
0 new messages