trinidad/trinidad_init_services — Issue #7: Ubuntu 10.04 LTS, Issues reading config file?
Author: boxofrad
Created: 2012-01-16 12:20:24+00:00
State: open

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:

```sh
-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:

```ruby
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 = {
:ivy_safaris => {
....... OMITTED .......
}
}
end
```
So my next logical step was to specify the config file in the init file on line 24 like so:

```sh
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:

```sh
/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:

```sh
[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:

```sh
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
- Daniel