Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jruby is binding jmx port multiple time #4650

Closed
Deepak1100 opened this issue Jun 7, 2017 · 3 comments
Closed

jruby is binding jmx port multiple time #4650

Deepak1100 opened this issue Jun 7, 2017 · 3 comments

Comments

@Deepak1100
Copy link

Deepak1100 commented Jun 7, 2017

Environment

Provide at least:

  • JRuby version (jruby -v) and command line (flags, JRUBY_OPTS, etc)
jruby 9.0.5.0 (2.2.3) 2016-01-26 7bee00d OpenJDK 64-Bit Server VM 25.72-b15 on 1.8.0_72-internal-b15 +jit [linux-amd64]
  • Operating system and platform (e.g. uname -a)

Other relevant info you may wish to add:

  • Installed or activated gems
  • Application/framework version (e.g. Rails, Sinatra)
  • Environment variables
 echo $JRUBY_OPTS
-J-Xms512m -J-Xmx2048m -J-Djava.rmi.server.hostname=localhost -J-javaagent:/app/jmx_prometheus_javaagent.jar=9999:/app/jmx_exporter.json

HI
I am trying to use jmx_exporter with jruby and it is trying to bind same port multiple time.
i have already seen this issue 1859 but my jruby version is already advance of 1.715

^C^Croot@52d9cca8b32d:/app# bundle exec  rails s
2017-06-07 13:08:46.110:INFO:ipjsoejs.Server:jetty-8.y.z-SNAPSHOT
2017-06-07 13:08:46.160:INFO:ipjsoejs.AbstractConnector:Started SelectChannelConnector@0.0.0.0:9999
2017-06-07 13:08:52.022:INFO:ipjsoejs.Server:jetty-8.y.z-SNAPSHOT
2017-06-07 13:08:52.065:WARN:ipjsoejuc.AbstractLifeCycle:FAILED SelectChannelConnector@0.0.0.0:9999: java.net.BindException: Address already in use
java.net.BindException: Address already in use
	at sun.nio.ch.Net.bind0(Native Method)
	at sun.nio.ch.Net.bind(Net.java:433)
	at sun.nio.ch.Net.bind(Net.java:425)
	at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
	at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
	at io.prometheus.jmx.shaded.org.eclipse.jetty.server.nio.SelectChannelConnector.open(SelectChannelConnector.java:187)
	at io.prometheus.jmx.shaded.org.eclipse.jetty.server.AbstractConnector.doStart(AbstractConnector.java:316)
	at io.prometheus.jmx.shaded.org.eclipse.jetty.server.nio.SelectChannelConnector.doStart(SelectChannelConnector.java:265)
	at io.prometheus.jmx.shaded.org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
	at io.prometheus.jmx.shaded.org.eclipse.jetty.server.Server.doStart(Server.java:288)
	at io.prometheus.jmx.shaded.org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
	at io.prometheus.jmx.shaded.io.prometheus.jmx.JavaAgent.premain(JavaAgent.java:33)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
	at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)
2017-06-07 13:08:52.067:WARN:ipjsoejuc.AbstractLifeCycle:FAILED io.prometheus.jmx.shaded.org.eclipse.jetty.server.Server@3fb6a447: java.net.BindException: Address already in use
java.net.BindException: Address already in use
	at sun.nio.ch.Net.bind0(Native Method)
	at sun.nio.ch.Net.bind(Net.java:433)
	at sun.nio.ch.Net.bind(Net.java:425)
	at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
	at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
	at io.prometheus.jmx.shaded.org.eclipse.jetty.server.nio.SelectChannelConnector.open(SelectChannelConnector.java:187)
	at io.prometheus.jmx.shaded.org.eclipse.jetty.server.AbstractConnector.doStart(AbstractConnector.java:316)
	at io.prometheus.jmx.shaded.org.eclipse.jetty.server.nio.SelectChannelConnector.doStart(SelectChannelConnector.java:265)
	at io.prometheus.jmx.shaded.org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
	at io.prometheus.jmx.shaded.org.eclipse.jetty.server.Server.doStart(Server.java:288)
	at io.prometheus.jmx.shaded.org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
	at io.prometheus.jmx.shaded.io.prometheus.jmx.JavaAgent.premain(JavaAgent.java:33)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
	at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)
Exception in thread "main" java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
	at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)
@kares
Copy link
Member

kares commented Jun 7, 2017

because you use bundle exec ... its not JRuby's fault, bundler is spawning 2 JVM (JRuby) processes.
you should use binstubs or you could try jruby -rbundler/setup -S rails s as an alternative.

@kares kares added this to the Invalid or Duplicate milestone Jun 7, 2017
@headius
Copy link
Member

headius commented Jun 9, 2017

@kares is right; we can't do anything about the bundle exec case since it always tries to launch two processes.

bundle exec for running Ruby commands and -rbundler/setup are also provided with the -G flag to JRuby.

So your command line should work fine (and faster!) as:

$ jruby -G -S rails s

Nothing to fix here unfortunately.

@headius headius closed this as completed Jun 9, 2017
@Deepak1100
Copy link
Author

@kares @headius thank for providing this info. it ran by using above commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants