Forum: Ruby slave-0.0.1

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Cb48ca5059faf7409a5ab3745a964696?d=identicon&s=25 Ara.T.Howard (Guest)
on 2006-06-09 00:05
(Received via mailing list)
URIS

   http://codeforpeople.com/lib/ruby/slave/
   http://rubyforge.org/frs/?group_id=1024&release_id=5631


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          # object becomes drb server in
another
                                     # process

     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

     obj = slave.object

                                     #
     p obj.method                    # call a method on drb server in
another
                                     # process

   other usage:

   set the pulse_rate used for the Heartbeat

     slave = Slave::new MyClass::new, 'pulse_rate' => 10

   same

     Slave::pulse_rate = 10
     slave = Slave::new MyClass::new

   same

     ENV['SLAVE_PULSE_RATE'] = 10
     slave = Slave::new MyClass::new

   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

INSTALL

   gem install slave


enjoy.

-a
573b9499030e1ccb867ef80f0ff1ac49?d=identicon&s=25 Justin Bailey (Guest)
on 2006-06-09 01:49
(Received via mailing list)
Ara,

I am trying to use your package on Windows. I'm running into an issue at
line 341 of slave.rb:

  @pipe.fcntl Fcntl::F_SETFD, Fcntl::FD_CLOEXEC

I'm curious what these flags mean and what their equivalent on Windows
might
be (if any).

I already solved a couple of issues (well, hacked around them):

1) No fork() on windows. Solved by installing Daniel Berger's
win32-process
gem
2) "drbunix" URI fails on non-unix. Solved by passing nil to
Drb.start_service (ugly hack, hoping to make it cleaner later)

Thanks for any help!

Justin
Cb48ca5059faf7409a5ab3745a964696?d=identicon&s=25 unknown (Guest)
on 2006-06-09 03:01
(Received via mailing list)
On Fri, 9 Jun 2006, Justin Bailey wrote:

hi justin-

> I am trying to use your package on Windows. I'm running into an issue at
> line 341 of slave.rb:
>
> @pipe.fcntl Fcntl::F_SETFD, Fcntl::FD_CLOEXEC
>
> I'm curious what these flags mean and what their equivalent on Windows might
> be (if any).

it means that, should the parent do something like

   exec 'another_program.exe'

the pipe will be closed.  it's important since pids are recycled and
pipes
transfered the slave would live on for while - perhaps indefinitely.

of course it's possible that behaviour is desireable, but then a zombie
would
also be created... anyhow, for hacking it's safe to comment that out.

> I already solved a couple of issues (well, hacked around them):
>
> 1) No fork() on windows. Solved by installing Daniel Berger's  win32-process
> gem
> 2) "drbunix" URI fails on non-unix. Solved by passing nil to
> Drb.start_service (ugly hack, hoping to make it cleaner later)

this could easily be configured - check out how the other stuff is
configured
and do something like allow the ENV var 'SLAVE_DRB_PROTOCOL' to override
this...  perhaps a better option might be

   Drb.start_server 'drb://localhost.localdomain:0'

note that 'nil' here doesn't work on macs for some reason...

i'm running out the door now, but i'd love to make this work on windows
- just
for the challenge.  maybe dan can lend a hand? ;-)

maybe we can work together and make another release that's portable.
ping me
offline if your're interested.

cheers.

-a
0b561a629b87f0bbf71b45ee5a48febb?d=identicon&s=25 Dave Burt (Guest)
on 2006-06-09 03:37
(Received via mailing list)
Ara.T.Howard wrote:
>   http://codeforpeople.com/lib/ruby/slave/
> ...
>   the Slave class forks a process and starts a drb server in the child
> ...
>     slave = Slave::new MyClass::new, 'pulse_rate' => 10

'Master' and 'Slave' labels unacceptable.

"Based on the cultural diversity and sensitivity of Los Angeles County,
this is not an acceptable identification label."

http://www.cnn.com/2003/TECH/ptech/11/26/master.term.reut/


Enjoy,
Dave
481b8eedcc884289756246e12d1869c1?d=identicon&s=25 Francis Cianfrocca (Guest)
on 2006-06-09 04:42
(Received via mailing list)
Cloexec doesn't exist on Windows. It would be meaningless anyway,
because
there's no notion of a fork. In effect, everything is cloexec.
Cb48ca5059faf7409a5ab3745a964696?d=identicon&s=25 unknown (Guest)
on 2006-06-09 04:56
(Received via mailing list)
On Fri, 9 Jun 2006, Francis Cianfrocca wrote:

> Cloexec doesn't exist on Windows. It would be meaningless anyway, because
> there's no notion of a fork. In effect, everything is cloexec.

everything on windows is meaningless to me ;-)  care to review the code
and
suggest a way to make it portable?

cheers.

-a
58479f76374a3ba3c69b9804163f39f4?d=identicon&s=25 Eric Hodel (Guest)
on 2006-06-11 06:44
(Received via mailing list)
On Jun 8, 2006, at 5:58 PM, ara.t.howard@noaa.gov wrote:

>
> note that 'nil' here doesn't work on macs for some reason...

IPv6?

--
Eric Hodel - drbrain@segment7.net - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com
This topic is locked and can not be replied to.