dev@grizzly.java.net

java.io.IOException: Too many open files in using Grizzly JRuby Web Server

From: Changshin Lee <iasandcb_at_gmail.com>
Date: Mon, 17 Sep 2007 00:37:44 +0900

Hi all,

Currently
I run a web site by Grizzly JRuby Web Server 1.6.0 with the following
command:

nohup java -Xmx512m -Djruby.jit.enabled=true -
Djruby.objectspace.enabled=false -jar ~/sw/grizzly-jruby/
jruby-1.6.0.jar -p 20001 -n 3 . &

And I got this error:

sun.reflect.GeneratedMethodAccessor10 invoke
Info: /home/nptf/www/xquared-site/config/../config/routes.rb (Too many
open files)^M
/home/nptf/www/xquared-site/config/../vendor/rails/actionpack/
lib/../../activesupport/lib/active_support/dependencies.rb:491:in
`load'^M
/home/nptf/www/xquared-site/config/../vendor/rails/actionpack/lib/
action_controller/routing.rb:1165:in `load_routes!'^M
/home/nptf/www/xquared-site/config/../vendor/rails/railties/lib/
dispatcher.rb:105:in `load!'^M
/home/nptf/www/xquared-site/config/../vendor/rails/railties/lib/
dispatcher.rb:105:in `prepare_application'^M
/home/nptf/www/xquared-site/config/../vendor/rails/railties/lib/
dispatcher.rb:39:in `dispatch'^M
dipsatch.rb:62

com.sun.grizzly.Controller doSelect
Fatal: doSelect exception
java.io.IOException: Too many open files
         at sun.nio.ch.ServerSocketChannelImpl.accept0(Native Method)
         at
sun.nio.ch.ServerSocketChannelImpl.accept(ServerSocketChannelImpl.java:
145)
         at
com
.sun
.grizzly
.TCPSelectorHandler.acceptWithoutRegistration(TCPSelectorHandler.java:
439)
         at
com
.sun
.grizzly.TCPSelectorHandler.onAcceptInterest(TCPSelectorHandler.java:
450)
         at com.sun.grizzly.Controller.doSelect(Controller.java:297)
         at com.sun.grizzly.Controller.start(Controller.java:788)
         at
com.sun.grizzly.http.SelectorThread.startListener(SelectorThread.java:
1080)
         at
com.sun.grizzly.http.SelectorThread.startEndpoint(SelectorThread.java:
1052)
         at com.sun.grizzly.standalone.JRuby.main(JRuby.java:114)

The current ulimit -n is 1024. What should I do to resolve this
problem? In more details,

1. What is a recommended number for ulimit -n ?
2. Is there any good way to run Grizzly JRuby Web Server as a daemon?

Thanks,

ias