Closed silverbucket closed 10 years ago
Basically what api.fork()
does is it spawns a new node process from lib/fork.js
which is simply just a call to api.setupServer()
you could call this function directly, but you wouldn't be able to get persistance, you'd get a nice RPC interface to handle multiple clients on though.
After api.fork()
is called, it will detach it's self from the forked child process, so if the parent dies, the child lives on. So say we call fork()
, it forks setupServer()
which creates two communication lines on specific ports. You can see this in action at https://github.com/ircanywhere/irc-factory/blob/master/client.js. To send commands to the RPC server you can emit events on the outgoing pipe, which are documented. All incoming irc events will come down the incoming line which you can listen to on message
. You'll get a special event called synchronize
at the start which will tell you how many clients it currently has if it's been disconnected.
I read in the README about the api.fork() function which somehow persists an IRC connection even after the parent thread is killed? I'm wonder how you manage to do this and what additional infrastructure needs to be in place if any? I was a little confused by that part.