SYNOPSIS the Slave class forks a process and starts a drb server in the child using any object as the server. the process is detached so it is not required (nor possible) to wait on the child pid. a Heartbeat is set up between the parent and child processes so that the child will exit of the parent exits for any reason - preventing orphaned slaves from running indefinitely. the purpose of Slaves is to be able to easily set up a collection of objects communicating via drb protocols instead of having to use IPC. typical usage: slave = Slave::new{ AnyObject.new } slave.object #=> handle on drb object slave.uri #=> uri of the drb object slave.socket #=> unix domain socket path for drb object slave.psname #=> title shown in ps/top object = slave.object value = object.any_method #=> use the object normally slaves may be configured via the environment, the Slave class, or via the ctor for object itself. attributes which may be configured include * object : specify the slave object. otherwise block value is used. * socket_creation_attempts : specify how many attempts to create a unix domain socket will be made * debug : turn on some logging to STDERR * psname : specify the name that will appear in 'top' ($0) * at_exit : specify a lambda to be called in the *parent* when the child dies * dumped : specify that the slave object should *not* be DRbUndumped (default is DRbUndumped) * threadsafe : wrap the slave object with ThreadSafe to implement gross thread safety URIS http://rubyforge.org/projects/codeforpeople/ http://codeforpeople.com/lib/ruby/slave HISTORY 1.2.0: - cleaned up a bunch of warnings. thanks eric kolve for reporting them. 1.1.0: - replaced HeartBeat class with LifeLine. - __HUGE__ cleanup of file descriptor/fork management with tons of help from skaar and ezra. thanks guys! - introduced Slave.object method used to return any object directory from a child process. see samples/g.rb. - indroduced keyword to automatically make slave objects threadsafe. remember that your slave object must be threadsafe because they are being server via DRb!!! 1.0.0: - THIS RELEASE IS !! NOT !! BACKWARD COMPATIBLE. NOTE NEW CTOR SYNTAX. - detach method also sets up at_exit handler. extra protection from zombies. - ezra zygmuntowicz asked for a feature whereby a parent could be notified when a child exited. obviously such a mechanism should be both async and sync. to accomplish this the wait method was extended to support a callback with is either sync or async slave = Server.new{ Server.new } slave.wait and puts 'this is sync!' slave.wait(:non_block=>true){ 'this is async!' } - patch to getval from skaar. the impl dropped opts delgating to the class method from the instance one. 0.2.0: incorporated joel vanderWerf's patch such that, if no object is passed the block is used to create one ONLY in the child. this avoids having a copy in both parent and child is that needs to be avoided due to, for instance, resource consumption. 0.0.1: - patch from Logan Capaldo adds block form to slave new, block is run in the child - added a few more samples/* - added Slave#wait - added status information to slaves - added close-on-exec flag to pipes in parent process 0.0.0: - initial version SAMPLES @samples