trinidad / trinidad_init_services

Run Trinidad as a service (based on Commons-Daemon and JRuby-JSVC)
Other
28 stars 10 forks source link

Ubuntu 10.04 LTS, Issues reading config file? #7

Closed boxofrad closed 12 years ago

boxofrad commented 12 years ago

Hi, our production server is running on Ubuntu 10.04. We've got trinidad working great when invoked manually like so:

sudo /opt/jruby/bin/jruby -S trinidad --config config/trinidad.rb

Installation of the init_services went find as did generation of the init.d file.

However when I went to run sudo /etc/init.d/trinidad start I received the following error:

-bash: /opt/jruby/lib/ruby/gems/1.8/gems/trinidad_init_services-1.1.0/trinidad-libs/jsvc_linux: No such file or directory

Naturally i checked the file existed and had appropriate permissions and all seemed fine.

A kind of fix for that was to manually install jsvc and point the init script at /usr/bin/jsvc.

Now the service tries to starts up but upon inspection of the log file I see the following errors:

16-Jan-2012 11:15:52 org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-localhost/127.0.0.1-0"]
16-Jan-2012 11:15:52 org.apache.catalina.core.StandardService startInternal
INFO: Starting service Tomcat
16-Jan-2012 11:15:52 org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.23
Invalid log level , using default: INFO
2012-01-16 11:15:52 INFO: No global web.xml found
2012-01-16 11:15:54 INFO: Warning: no max runtimes specified.
2012-01-16 11:15:54 INFO: jruby 1.6.5.1 (ruby-1.8.7-p330) (2011-12-27 1bf37c2) (OpenJDK 64-Bit Server VM 1.6.0_20) [linux-amd64-java]
2012-01-16 11:15:54 INFO: Info: using runtime pool timeout of 30 seconds
2012-01-16 11:15:54 INFO: Warning: no min runtimes specified.
2012-01-16 11:15:54 INFO: Warning: no max runtimes specified.
2012-01-16 11:15:54 SEVERE: Failed to start connector [Connector[HTTP/1.1-0]]

This leads me to believe that it is not reading my configuration file as I have specified log level and min/max runtimes like so:

Trinidad.configure do |t|
  t.port = 80  t.address = 'localhost'
  t.environment = 'production'
  t.log = 'INFO'

  t.jruby_min_runtimes = 1
  t.jruby_max_runtimes = 5

  t.web_apps = {
    :client_website => {
        ....... OMITTED .......
    }
  }
end

So my next logical step was to specify the config file in the init file on line 24 like so:

TRINIDAD_OPTS="-d /var/webapps --config /var/webapps/config/trinidad.rb"

Again no dice!

So as a last resort I edited the init script to print the $START_COMMAND and it outputs the following:

/usr/bin/jsvc -home /usr/lib/jvm/java-6-openjdk/jre -wait 20 -pidfile /var/run/trinidad/trinidad.pid -user root -procname jsvc- -jvm server -outfile /var/log/trinidad/trinidad.log -errfile &1 -cp /opt/jruby/lib/ruby/gems/1.8/gems/trinidad_init_services-1.1.0/trinidad-libs/jruby-jsvc.jar:/opt/jruby/lib/ruby/gems/1.8/gems/trinidad_init_services-1.1.0/trinidad-libs/commons-daemon.jar:/opt/jruby/lib/jruby.jar -Djruby.memory.max=500m -Djruby.stack.max=1024k -Djna.boot.library.path=/opt/jruby/lib/native/linux-i386:/opt/jruby/lib/native/linux-amd64 -Djffi.boot.library.path=/opt/jruby/lib/native/i386-Linux:/opt/jruby/lib/native/s390x-Linux:/opt/jruby/lib/native/x86_64-Linux -Djruby.shell=/bin/sh -Djruby.home=/opt/jruby -Djruby.lib=/opt/jruby/lib -Djruby.script=jruby -Djruby.daemon.module.name=Trinidad -Djruby.compat.version=RUBY1_8 -Xmx500m -Xss1024k -Xbootclasspath/a:/opt/jruby/lib/jruby.jar com.msp.jsvc.JRubyDaemon /opt/jruby/lib/ruby/gems/1.8/gems/trinidad_init_services-1.1.0/lib/trinidad_init_services.rb -d /var/webapps --config /var/webapps/config/trinidad.rb 

I dropped that into a terminal and it returns:

[1] 992
Invalid Error File specified
Cannot parse command line arguments
1: command not found
[1]+  Exit 1                  /usr/bin/jsvc -home /usr/lib/jvm/java-6-openjdk/jre -wait 20 -pidfile /var/run/trinidad/trinidad.pid -user root -procname jsvc- -jvm server -outfile /var/log/trinidad/trinidad.log -errfile

On inspection of this i figured it was an issue with the -errfile option and how your using the &1 option to send it to stdout. So i tried wrapping this in quotes like so: '&1' and the command itself exits successfully.

But upon inspection of the log file I still see the same error:

16-Jan-2012 11:49:28 org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-localhost/127.0.0.1-0"]
16-Jan-2012 11:49:28 org.apache.catalina.core.StandardService startInternal
INFO: Starting service Tomcat
16-Jan-2012 11:49:28 org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.23
Invalid log level , using default: INFO
2012-01-16 11:49:28 INFO: No global web.xml found
2012-01-16 11:49:30 INFO: Warning: no max runtimes specified.
2012-01-16 11:49:30 INFO: jruby 1.6.5.1 (ruby-1.8.7-p330) (2011-12-27 1bf37c2) (OpenJDK 64-Bit Server VM 1.6.0_20) [linux-amd64-java]
2012-01-16 11:49:30 INFO: Info: using runtime pool timeout of 30 seconds
2012-01-16 11:49:30 INFO: Warning: no min runtimes specified.
2012-01-16 11:49:30 INFO: Warning: no max runtimes specified.
2012-01-16 11:49:30 SEVERE: Failed to start connector [Connector[HTTP/1.1-0]]

Where is it going wrong?

Thankyou in advance

kares commented 12 years ago

I have reviewed your jsvc command and seems the same as mine, except for -user switch which I had issues with and I do not use at all (I rather do a sudo and run under a non-root user). there's smt weird as -errfile &1 works for me as well (I am on Debian).

boxofrad commented 12 years ago

Thanks for having a look @kares

For now an interim solution is to use the YAML config file (which gets loaded by default).

I'm also having an issue with the -user flag, but only root can bind to port 80. So i'm actually running tomcat on 8080 and proxying with nginx..

Which is probably a better idea for production anyway! :)

kares commented 12 years ago

so replacing /var/webapps/config/trinidad.rb with an equivalent /var/webapps/config/trinidad.yml worked ? or did you change something else as well ... just so we know where to proceed with this issue.

jkutner commented 12 years ago

The jsvc that's packaged with the gem doesn't seem to work on Ubuntu 10.4 -- that's why I added the jsvc path as an option in the init services config YAML. Installing it yourself if probably the best thing to do, since it would be hard to cover every platform.

boxofrad commented 12 years ago

Yep, replacing it with the equivalent YAML file fixed it..

boxofrad commented 12 years ago

@jkutner

Okay thats cool.. Maybe we should update the README or add a wiki page about it. Or even prompt the user about it on installation?

What do you think is best?

jkutner commented 12 years ago

Yea, I think jsvc should be one of the option that you are prompted for. I'l definately update the README, too. Thx

boxofrad commented 12 years ago

Great! thanks for your help :)

jkutner commented 12 years ago

I'm able to reproduce this -- but not on purpose unfortunately. @kares fix seems to work though. Can we get a 1.1.3 release soon?