adhearsion / adhearsion-drb

adhearsion-drb is an Adhearsion Plugin providing DRb connectivity. It allows third party ruby clients to connect to an Adhearsion instance for RPC.
MIT License
10 stars 4 forks source link

Failed to start DRB: port already in use #6

Open JustinAiken opened 10 years ago

JustinAiken commented 10 years ago

I've occasionally seen adhearsion-drb fail to initialize, both legitimately (something already had the port), or freakishly randomly. No log at the moment, I'll try to capture one next time I see a random fail...

But, if it does fail, it just logs a one-line error, and the adhearsion up starts up normally. Most applications using adhearsion-drb probably rely on it for core functionallity, so I think adhearsion-drb should either:

Any thoughts about better failure handling?

benlangfeld commented 10 years ago

I'll come back to better handling the failure later. For now, how are you ascertaining that nothing is holding the port?

JustinAiken commented 10 years ago

If I kill ahn and immediately start it again, it works.. thought it was a Vagrant networking thing while I was developing it, but also seeing it on a live staging server too.

benlangfeld commented 10 years ago

How do you kill ahn? killall ahn, or targeted at a particular PID?

JustinAiken commented 10 years ago

In development, ctrl-c, in staging restarting it with God, which executes:

"cd #{@talkbox_path} && bundle exec ahn stop . && bundle exec ahn daemon ."
JustinAiken commented 10 years ago
[2013-11-12 16:25:19] INFO  Adhearsion::Drb::Plugin::Service: Starting DRb on 0.0.0.0:9050
[2013-11-12 16:25:19] DEBUG Celluloid: Terminating 4 actors...
[2013-11-12 16:25:19] DEBUG Punchblock::Connection::Asterisk: Finalizing stream
/usr/local/lib/ruby/1.9.1/drb/drb.rb:861:in `initialize': Address already in use - bind(2) (Errno::EADDRINUSE)
    from /usr/local/lib/ruby/1.9.1/drb/drb.rb:861:in `open'
    from /usr/local/lib/ruby/1.9.1/drb/drb.rb:861:in `open_server'
    from /usr/local/lib/ruby/1.9.1/drb/drb.rb:759:in `block in open_server'
    from /usr/local/lib/ruby/1.9.1/drb/drb.rb:757:in `each'
    from /usr/local/lib/ruby/1.9.1/drb/drb.rb:757:in `open_server'
    from /usr/local/lib/ruby/1.9.1/drb/drb.rb:1342:in `initialize'
    from /usr/local/lib/ruby/1.9.1/drb/drb.rb:1624:in `new'
    from /usr/local/lib/ruby/1.9.1/drb/drb.rb:1624:in `start_service'
    from /data/apps/talkbox/shared/bundle/ruby/1.9.1/gems/adhearsion-drb-1.0.0/lib/adhearsion/drb/plugin/service.rb:19:in `start'
    from /data/apps/talkbox/shared/bundle/ruby/1.9.1/gems/adhearsion-drb-1.0.0/lib/adhearsion/drb/plugin.rb:27:in `block in <class:Plugin>'
    from /data/apps/talkbox/shared/bundle/ruby/1.9.1/gems/adhearsion-2.4.0/lib/adhearsion/plugin/initializer.rb:26:in `instance_exec'
    from /data/apps/talkbox/shared/bundle/ruby/1.9.1/gems/adhearsion-2.4.0/lib/adhearsion/plugin/initializer.rb:26:in `run'
    from /data/apps/talkbox/shared/bundle/ruby/1.9.1/gems/adhearsion-2.4.0/lib/adhearsion/plugin.rb:168:in `block in init_plugins'
    from /data/apps/talkbox/shared/bundle/ruby/1.9.1/gems/adhearsion-2.4.0/lib/adhearsion/plugin.rb:167:in `each'
    from /data/apps/talkbox/shared/bundle/ruby/1.9.1/gems/adhearsion-2.4.0/lib/adhearsion/plugin.rb:167:in `init_plugins'
    from /data/apps/talkbox/shared/bundle/ruby/1.9.1/gems/adhearsion-2.4.0/lib/adhearsion/initializer.rb:229:in `init_plugins'
    from /data/apps/talkbox/shared/bundle/ruby/1.9.1/gems/adhearsion-2.4.0/lib/adhearsion/initializer.rb:61:in `block in start'
    from /data/apps/talkbox/shared/bundle/ruby/1.9.1/gems/adhearsion-2.4.0/lib/adhearsion/initializer.rb:41:in `catch'
    from /data/apps/talkbox/shared/bundle/ruby/1.9.1/gems/adhearsion-2.4.0/lib/adhearsion/initializer.rb:41:in `start'
    from /data/apps/talkbox/shared/bundle/ruby/1.9.1/gems/adhearsion-2.4.0/lib/adhearsion/initializer.rb:12:in `start'
    from /data/apps/talkbox/shared/bundle/ruby/1.9.1/gems/adhearsion-2.4.0/lib/adhearsion/cli_commands/ahn_command.rb:103:in `start_app'
    from /data/apps/talkbox/shared/bundle/ruby/1.9.1/gems/adhearsion-2.4.0/lib/adhearsion/cli_commands/ahn_command.rb:48:in `daemon'
    from /data/apps/talkbox/shared/bundle/ruby/1.9.1/gems/thor-0.18.1/lib/thor/command.rb:27:in `run'
    from /data/apps/talkbox/shared/bundle/ruby/1.9.1/gems/thor-0.18.1/lib/thor/invocation.rb:120:in `invoke_command'
    from /data/apps/talkbox/shared/bundle/ruby/1.9.1/gems/thor-0.18.1/lib/thor.rb:363:in `dispatch'
    from /data/apps/talkbox/shared/bundle/ruby/1.9.1/gems/thor-0.18.1/lib/thor/base.rb:439:in `start'
    from script/ahn:9:in `<main>'
bklang commented 10 years ago

This implies some other process already has the port open. Is it possible that you have another instance of Adhearsion (perhaps not quite shutdown) still running? Even another Ruby process using DRb on the same port?

JustinAiken commented 10 years ago

No other ahn running at the time... forgot to netstat when it happened to see if anything listening to the port, will next time it occurs.