stopping a drb server

Discussion in 'Ruby' started by Mark Volkmann, Jul 17, 2005.

  1. Should I be able to stop a drb server that ends with

    DRb.thread.join=20

    by hitting Ctrl-C?

    http://segment7.net/projects/ruby/drb/introduction.html says that should wo=
    rk.
    It's not working for me.

    Maybe there's additional code I need to add to enable that.

    --=20
    R. Mark Volkmann
    Partner, Object Computing, Inc.
    Mark Volkmann, Jul 17, 2005
    #1
    1. Advertising

  2. Mark Volkmann

    Eric Hodel Guest

    On 17 Jul 2005, at 13:52, Mark Volkmann wrote:

    > Should I be able to stop a drb server that ends with
    >
    > DRb.thread.join
    >
    > by hitting Ctrl-C?
    >
    > http://segment7.net/projects/ruby/drb/introduction.html says that
    > should work.
    > It's not working for me.
    >
    > Maybe there's additional code I need to add to enable that.


    Shouldn't be...

    What platform? Is you DNS working? DRb performs a DNS lookup to
    discover your local hostname.

    $ cat simple_server.rb
    #!/usr/bin/env ruby -w
    # simple_service.rb
    # A simple DRb service

    # load DRb
    require 'drb'

    # start up the DRb service
    DRb.start_service nil, []

    # We need the uri of the service to connect a client
    puts DRb.uri

    # wait for the DRb service to finish before exiting
    DRb.thread.join
    $ ruby -v simple_server.rb
    ruby 1.8.3 (2005-06-17) [powerpc-darwin8.1.0]
    druby://kaa.local:58927
    ^Csimple_server.rb:15:in `join': Interrupt
    from simple_server.rb:15
    $

    --
    Eric Hodel - - http://segment7.net
    FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04
    Eric Hodel, Jul 17, 2005
    #2
    1. Advertising

  3. On 7/17/05, Eric Hodel <> wrote:
    >=20
    > On 17 Jul 2005, at 13:52, Mark Volkmann wrote:
    >=20
    > > Should I be able to stop a drb server that ends with
    > >
    > > DRb.thread.join
    > >
    > > by hitting Ctrl-C?
    > >
    > > http://segment7.net/projects/ruby/drb/introduction.html says that
    > > should work.
    > > It's not working for me.
    > >
    > > Maybe there's additional code I need to add to enable that.

    >=20
    > Shouldn't be...
    >=20
    > What platform?


    Windows XP

    > Is you DNS working? DRb performs a DNS lookup to
    > discover your local hostname.


    Yes. I verified that by doing a ping from a command prompt on a known
    URL. It pinged the correct IP address.

    > $ cat simple_server.rb
    > #!/usr/bin/env ruby -w
    > # simple_service.rb
    > # A simple DRb service
    >=20
    > # load DRb
    > require 'drb'
    >=20
    > # start up the DRb service
    > DRb.start_service nil, []
    >=20
    > # We need the uri of the service to connect a client
    > puts DRb.uri
    >=20
    > # wait for the DRb service to finish before exiting
    > DRb.thread.join
    > $ ruby -v simple_server.rb
    > ruby 1.8.3 (2005-06-17) [powerpc-darwin8.1.0]
    > druby://kaa.local:58927
    > ^Csimple_server.rb:15:in `join': Interrupt
    > from simple_server.rb:15


    I ran your code and was not able to break out with a Ctrl-c.
    Could this be a Windows-specific problem?

    --=20
    R. Mark Volkmann
    Partner, Object Computing, Inc.
    Mark Volkmann, Jul 17, 2005
    #3
  4. Mark Volkmann

    Hal Fulton Guest

    Mark Volkmann wrote:
    >
    > I ran your code and was not able to break out with a Ctrl-c.
    > Could this be a Windows-specific problem?
    >


    I think it is -- I seem to recall being annoyed by this before.

    I believe I ended up starting another thread that would do a 'gets'
    or something and then kill the other threads after it saw the user
    hit the keyboard.

    This may also be problematic if e.g. you first hit some other key
    besides enter -- I think that cause(s|d) problems.


    Hal
    Hal Fulton, Jul 17, 2005
    #4
  5. Mark Volkmann

    daz Guest

    Mark Volkmann wrote:
    > On 7/17/05, Eric Hodel wrote:
    > >
    > > What platform?

    >
    > Windows XP
    >
    > [...]
    > I ran your code and was not able to break out with a Ctrl-c.
    > Could this be a Windows-specific problem?
    >
    > R. Mark Volkmann



    Try Ctrl-Break.

    If that doesn't clear it, Ctrl-c now should.

    (Ctrl-Break-c and Ctrl-c-Break alternatives often work.)

    Can't point you to an explanation, sorry.


    daz
    daz, Jul 18, 2005
    #5
  6. Mark Volkmann

    Eric Hodel Guest

    On 17 Jul 2005, at 14:51, Mark Volkmann wrote:

    > On 7/17/05, Eric Hodel <> wrote:
    >
    >> Shouldn't be...
    >>
    >> What platform?
    >>

    >
    > Windows XP
    >
    >> Is you DNS working? DRb performs a DNS lookup to
    >> discover your local hostname.
    >>

    >
    > Yes. I verified that by doing a ping from a command prompt on a known
    > URL. It pinged the correct IP address.


    You need to also verify that forward and reverse DNS for your machine
    are both set up.

    >> $ cat simple_server.rb
    >> #!/usr/bin/env ruby -w
    >> # simple_service.rb
    >> # A simple DRb service
    >>
    >> # load DRb
    >> require 'drb'
    >>
    >> # start up the DRb service
    >> DRb.start_service nil, []
    >>
    >> # We need the uri of the service to connect a client
    >> puts DRb.uri
    >>
    >> # wait for the DRb service to finish before exiting
    >> DRb.thread.join
    >> $ ruby -v simple_server.rb
    >> ruby 1.8.3 (2005-06-17) [powerpc-darwin8.1.0]
    >> druby://kaa.local:58927
    >> ^Csimple_server.rb:15:in `join': Interrupt
    >> from simple_server.rb:15
    >>

    >
    > I ran your code and was not able to break out with a Ctrl-c.
    > Could this be a Windows-specific problem?


    Did you get the druby:// line?

    --
    Eric Hodel - - http://segment7.net
    FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04
    Eric Hodel, Jul 18, 2005
    #6
  7. Mark Volkmann

    Eric Hodel Guest

    On 17 Jul 2005, at 14:56, Hal Fulton wrote:

    > Mark Volkmann wrote:
    >
    >> I ran your code and was not able to break out with a Ctrl-c.
    >> Could this be a Windows-specific problem?
    >>

    >
    > I think it is -- I seem to recall being annoyed by this before.
    >
    > I believe I ended up starting another thread that would do a 'gets'
    > or something and then kill the other threads after it saw the user
    > hit the keyboard.
    >
    > This may also be problematic if e.g. you first hit some other key
    > besides enter -- I think that cause(s|d) problems.


    The example code doesn't use gets, so I think it is somewhere else.

    --
    Eric Hodel - - http://segment7.net
    FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04
    Eric Hodel, Jul 18, 2005
    #7
  8. On 7/18/05, Eric Hodel <> wrote:

    > Did you get the druby:// line?


    Yes. It output "druby://volkmann:1081".
    "volkmann" is my host name.

    Ctrl-Break works for me, but not Ctrl-c.

    --=20
    R. Mark Volkmann
    Partner, Object Computing, Inc.
    Mark Volkmann, Jul 19, 2005
    #8
  9. Mark Volkmann

    Eric Hodel Guest

    On 19 Jul 2005, at 08:06, Mark Volkmann wrote:

    > On 7/18/05, Eric Hodel <> wrote:
    >
    >
    >> Did you get the druby:// line?
    >>

    >
    > Yes. It output "druby://volkmann:1081".
    > "volkmann" is my host name.
    >
    > Ctrl-Break works for me, but not Ctrl-c.


    I'm at a loss then. You'd have to look inside the process and see
    what its stuck on.

    --
    Eric Hodel - - http://segment7.net
    FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04
    Eric Hodel, Jul 20, 2005
    #9
  10. Eric Hodel wrote:
    > On 19 Jul 2005, at 08:06, Mark Volkmann wrote:
    >> On 7/18/05, Eric Hodel <> wrote:
    >> Ctrl-Break works for me, but not Ctrl-c.

    >
    > I'm at a loss then. You'd have to look inside the process and see what
    > its stuck on.


    I haven't really followed this thead, but this message prompted me to
    dig out some 20-year-old Turbo C code for an ancient DOS application. As
    I recall, ctrl-c interrupt had to be explicitly enabled.

    The code I found called setcbrk(1) to enable trap on ctrl-c. Don't know
    if MSVC has (or requires) an equivalent.

    Steve
    Steven Jenkins, Jul 20, 2005
    #10
  11. Mark Volkmann <> writes:

    > On 7/18/05, Eric Hodel <> wrote:
    >
    >> Did you get the druby:// line?

    >
    > Yes. It output "druby://volkmann:1081".
    > "volkmann" is my host name.
    >
    > Ctrl-Break works for me, but not Ctrl-c.


    You must be using MSVC-compiled ruby, right?

    The reason is ruby doesn't enable handling of ctrl event in
    win32 (would need to be corrected).

    Ctrl-Break works for you because win32 installs a default handler for
    ctrl-break which would kill the process.

    But there is no default handler for ctrl-c.

    http://www.thecodeproject.com/win32/console_event_handling.asp

    There is also a MSDN link I'd like to show here that describes that
    ctrl-break has a default handler and ctrl-c doesn't, but I couldn't
    find it.

    YS.
    Yohanes Santoso, Jul 20, 2005
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Miles Keaton
    Replies:
    3
    Views:
    179
    Miles Keaton
    Mar 30, 2005
  2. Kirk Haines

    More DRb; SSL & DRB & errors

    Kirk Haines, Jul 1, 2005, in forum: Ruby
    Replies:
    0
    Views:
    123
    Kirk Haines
    Jul 1, 2005
  3. J. Wook
    Replies:
    16
    Views:
    281
    Robert Klemme
    May 16, 2007
  4. Ittay Dror
    Replies:
    1
    Views:
    133
    Ittay Dror
    Oct 21, 2008
  5. Christopher Dancy

    Stopping a specific DRb service

    Christopher Dancy, May 24, 2010, in forum: Ruby
    Replies:
    1
    Views:
    121
    Christopher Dancy
    May 25, 2010
Loading...

Share This Page