# RAGI Gem - Running an additional server thread

**URL:** <https://www.ruby-forum.com/t/ragi-gem-running-an-additional-server-thread/99735>\
**Category:** Rails\
**Created:** [February 1, 2006, 4:29pm UTC](https://www.ruby-forum.com/t/ragi-gem-running-an-additional-server-thread/99735 "2006-02-01T16:29:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![muppetmaster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/90db22/32.png) [@muppetmaster](https://www.ruby-forum.com/u/muppetmaster)\
**Post date:** [February 1, 2006, 4:29pm UTC](https://www.ruby-forum.com/t/ragi-gem-running-an-additional-server-thread/99735/1 "2006-02-01T16:29:14Z")

</div>

I have RoR running and have configured RAGI (per the new tutorial  
provided at ETel [http://www.snapvine.com/code/ragi](http://www.snapvine.com/code/ragi)) but I get this:

* * *

## user# script/server =\> Booting WEBrick… [2006-01-30 14:20:25] INFO RAGI::CallServer: default-handler= port=4573 [2006-01-30 14:20:25] INFO WEBrick 1.3.1 [2006-01-30 14:20:25] INFO ruby 1.8.2 (2004-12-25) [i586-linux] [2006-01-30 14:20:25] WARN TCPServer Error: Address already in use - bind(2) [2006-01-30 14:20:25] INFO WEBrick::GenericServer#start: pid=13375 port=4573 [2006-01-30 14:20:25] INFO RAGI::CallServer: server shutdown port=4573 =\> Rails application started on [http://0.0.0.0:3000](http://0.0.0.0:3000) =\> Ctrl-C to shutdown server; call with --help for options [2006-01-30 14:20:25] INFO WEBrick 1.3.1 [2006-01-30 14:20:25] INFO ruby 1.8.2 (2004-12-25) [i586-linux] [2006-01-30 14:20:25] INFO WEBrick::HTTPServer#start: pid=13375 port=3000

Nothing is configured to run on (xinetd) or is running on port 4573, and  
yet I get this error. Also, I tried to change the default port in:

ragi-1.0.1/ragi # vi config.rb

but I get the same error for any port I try to use. How do I get this to  
work?

---

<div class="post-metadata">

**Author:** ![muppetmaster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/90db22/32.png) [@muppetmaster](https://www.ruby-forum.com/u/muppetmaster)\
**Post date:** [February 2, 2006, 5:15pm UTC](https://www.ruby-forum.com/t/ragi-gem-running-an-additional-server-thread/99735/2 "2006-02-02T17:15:59Z")

</div>

Use config.rb for standalone RAGI programs. If you want RAGI to run  
from within Rails, instead place something like the following in  
environment.rb (not config.rb)

# ragi configuration

require ‘webrick’

Dependencies.mechanism = :require # class loading magic

class SimpleThreadServer \< WEBrick::SimpleServer  
def SimpleThreadServer.start(&block)  
Thread.new do block.call  
end  
end  
end

require ‘ragi/call\_server’

RAGI::CallServer.new(:ServerType =\> SimpleThreadServer )

I’ve found that it works best for me when I place ragi under the lib  
directory in the rails project. If you have more problems, please post  
more details … also check that there are no existing instances of  
ragi or other asterisk gateway interface programs.

You can always try doing telnet to port 4573 (e.g. telnet localhost  
4573) to verify that there’s nothing running on that port. If there’s  
nothing running, you should get connection refused.

– G.
