A
ara.t.howard
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:
obj = AnyClass::new
slave = Slave::new obj
p slave.object # handle on drb object
p slave.uri # uri of the drb object
p slave.socket # unix domain socket path for drb object
p slave.psname # title shown in ps/top
other usage:
set the pulse_rate used for the Heartbeat
slave = Slave::new MyClass::new, 'pulse_rate' => 10
same
Slave:ulse_rate = 10
slave = Slave::new MyClass::new
same
ENV['SLAVE_PULSE_RATE'] = 10
slave = Slave::new MyClass::new
to avoid having a copy of the object in both the parent and child use the
block form
slave = Slave::new{ Server::new } # copy only in child!
server = slave.object
if both an object AND a block are passed the object is passed to the block
in the child process
slave = Slave::new(Server::new){|server| p 'in child!' }
slaves may be configured via the environment, the Slave class, or via the
ctor for object itself. attributes which may be configured include
* socket_creation_attempts
* pulse_rate
* psname
* debug
HISTORY
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
enjoy.
-a
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:
obj = AnyClass::new
slave = Slave::new obj
p slave.object # handle on drb object
p slave.uri # uri of the drb object
p slave.socket # unix domain socket path for drb object
p slave.psname # title shown in ps/top
other usage:
set the pulse_rate used for the Heartbeat
slave = Slave::new MyClass::new, 'pulse_rate' => 10
same
Slave:ulse_rate = 10
slave = Slave::new MyClass::new
same
ENV['SLAVE_PULSE_RATE'] = 10
slave = Slave::new MyClass::new
to avoid having a copy of the object in both the parent and child use the
block form
slave = Slave::new{ Server::new } # copy only in child!
server = slave.object
if both an object AND a block are passed the object is passed to the block
in the child process
slave = Slave::new(Server::new){|server| p 'in child!' }
slaves may be configured via the environment, the Slave class, or via the
ctor for object itself. attributes which may be configured include
* socket_creation_attempts
* pulse_rate
* psname
* debug
HISTORY
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
enjoy.
-a