trinidad/trinidad — Issue #48: no such file to load -- rack/handler
Author: paulwalker
Created: 2012-01-23 20:12:22+00:00
State: open

Using trinidad 1.3.2, trinidad_jars 1.0.2, and a trinidad_init_services 1.1.2

This occurs either when running the init.d script or simply trying to start up via the command line:
trinidad -e production.

This is the stack trace using the init.d script:

org.jruby.exceptions.RaiseException: (LoadError) no such file to load -- rack/handler
at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1038)
at Kernel.require(/home/deploy/.rvm/rubies/jruby-1.6.5/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36)
at #.(root)(/home/deploy/.rvm/gems/jruby-1.6.5/gems/trinidad-1.3.2/lib/rack/handler/trinidad.rb:3)
at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1038)
at Kernel.require(/home/deploy/.rvm/gems/jruby-1.6.5/gems/trinidad-1.3.2/lib/rack/handler/trinidad.rb:36)
at #.(root)(/home/deploy/.rvm/gems/jruby-1.6.5/gems/trinidad-1.3.2/lib/trinidad.rb:21)
at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1038)
at Kernel.require(/home/deploy/.rvm/gems/jruby-1.6.5/gems/trinidad-1.3.2/lib/trinidad.rb:59)
at home.deploy.$_dot_rvm.gems.jruby_minus_1_dot_6_dot_5.gems.trinidad_init_services_minus_1_dot_1_dot_2.lib.trinidad_init_services.(root)(/home/deploy/.rvm/gems/jruby-1.6.5/gems/trinidad_init_services-1.1.2/lib/trinidad_init_services.rb:2)

This is the stack trace via the command line:

LoadError: no such file to load -- rack/handler
require at org/jruby/RubyKernel.java:1038
require at /home/deploy/.rvm/rubies/jruby-1.6.5/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36
(root) at /home/deploy/.rvm/gems/jruby-1.6.5/gems/trinidad-1.3.2/lib/rack/handler/trinidad.rb:3
require at org/jruby/RubyKernel.java:1038
require at /home/deploy/.rvm/gems/jruby-1.6.5/gems/trinidad-1.3.2/lib/rack/handler/trinidad.rb:36
(root) at /home/deploy/.rvm/gems/jruby-1.6.5/gems/trinidad-1.3.2/lib/trinidad.rb:21
require at org/jruby/RubyKernel.java:1038
require at /home/deploy/.rvm/gems/jruby-1.6.5/gems/trinidad-1.3.2/lib/trinidad.rb:36
(root) at /home/deploy/.rvm/gems/jruby-1.6.5/gems/trinidad-1.3.2/bin/trinidad:3
load at org/jruby/RubyKernel.java:1063
(root) at /home/deploy/.rvm/gems/jruby-1.6.5/bin/trinidad:19

For good measure, here is the init.d script, but obviously I don't think it's related.

#!/usr/bin/env bash
# Generic script for running ruby scripts as daemons using
# jsvc and a java class to control the daemon.
#
# Contains common parameters and start/stop

# Things you'll need to set on a per script/daemon basis:
# APP_NAME - name of your application (defaults to "trinidad")
#
# Things you can set:
# PROG_OPTS - Arguments to send to the program. A few defaults are appended to this.

JSVC=/usr/bin/jsvc
#/home/deploy/.rvm/gems/jruby-1.6.5/gems/trinidad_init_services-1.1.2/trinidad-libs/jsvc_linux
JAVA_HOME=/usr/lib/jvm/java-6-openjdk/jre
JRUBY_HOME=/home/deploy/.rvm/rubies/jruby-1.6.5
APP_PATH=/u/apps/roambi-store/current
RUBY_SCRIPT=/home/deploy/.rvm/gems/jruby-1.6.5/gems/trinidad_init_services-1.1.2/lib/trinidad_init_services.rb

# Add here the options that Trinidad needs to run your application,
# but DO NOT delete the -d option, i.e -e production
TRINIDAD_OPTS="-d /u/apps/roambi-store/current -e production"

PIDFILE=/u/apps/roambi-store/current/tmp/pids/trinidad.pid
LOG_FILE=/u/apps/roambi-store/current/log/trinidad.log

# Implements the jsvc Daemon interface.
MAIN_CLASS=com.msp.jsvc.JRubyDaemon

CLASSPATH=/home/deploy/.rvm/gems/jruby-1.6.5/gems/trinidad_init_services-1.1.2/trinidad-libs/jruby-jsvc.jar:/home/deploy/.rvm/gems/jruby-1.6.5/gems/trinidad_init_services-1.1.2/trinidad-libs/commons-daemon.jar:/home/deploy/.rvm/rubies/jruby-1.6.5/lib/jruby.jar

if [ -z "$JRUBY_OPTS" ] ; then
JRUBY_OPTS=""
fi

# TODO: Allow configuration or detect from the OS
JAVA_NATIVE_PROPS="-Djna.boot.library.path=$JRUBY_HOME/lib/native/linux-i386:$JRUBY_HOME/lib/native/linux-amd64 \
-Djffi.boot.library.path=$JRUBY_HOME/lib/native/i386-Linux:$JRUBY_HOME/lib/native/s390x-Linux:$JRUBY_HOME/lib/native/x86_64-Linux"

JAVA_PROPS="$JAVA_PROPS -Djruby.memory.max=500m \
-Djruby.stack.max=1024k \
$JAVA_NATIVE_PROPS \
-Djruby.shell=/bin/sh \
-Djruby.home=/home/deploy/.rvm/rubies/jruby-1.6.5 -Djruby.lib=/home/deploy/.rvm/rubies/jruby-1.6.5/lib -Djruby.script=jruby -Djruby.daemon.module.name=Trinidad -Djruby.compat.version=RUBY1_8 \
$JRUBY_OPTS"

JAVA_OPTS="-Xmx500m -Xss1024k -Xbootclasspath/a:$JRUBY_HOME/lib/jruby.jar"
PROC_NAME=${SCRIPT_NAME:-${APP_NAME:-"trinidad"}}

JSVC_ARGS="-home $JAVA_HOME \
$JSVC_ARGS_EXTRA \
-wait 20 \
-pidfile $PIDFILE \
-user $USER \
-procname jsvc-$PROC_NAME \
-jvm server
-outfile $LOG_FILE \
-errfile &1"

#
# Stop/Start
#

STOP_COMMAND="$JSVC $JSVC_ARGS -stop $MAIN_CLASS"
START_COMMAND="$JSVC $JSVC_ARGS -cp $CLASSPATH $JAVA_PROPS $JAVA_OPTS $MAIN_CLASS $RUBY_SCRIPT $TRINIDAD_OPTS"

cd $APP_PATH || exit 1

case "$1" in
start)
if [ -e "$PIDFILE" ]; then
echo "Pidfile already exists, not starting."
exit 1
else
echo "Starting $PROC_NAME daemon..."
$START_COMMAND
EXIT_CODE=$?
if [ "$EXIT_CODE" != 0 ]; then
echo "Daemon exited with status: $EXIT_CODE. Check pidfile and log"
fi
fi
;;
stop)
if [ -e "$PIDFILE" ]; then
echo "Stopping $PROC_NAME daemon..."
$STOP_COMMAND
else
echo "No pid file, not stopping."
exit 1
fi
;;
restart)
if [ -e "$PIDFILE" ]; then
echo "Stopping $PROC_NAME daemon..."
$STOP_COMMAND
fi
if [ -e "$PIDFILE" ]; then
echo "Pidfile still present, $PROC_NAME hasn't stopped"
exit 1
else
$START_COMMAND
EXIT_CODE=$?
if [ "$EXIT_CODE" != 0 ]; then
echo "Daemon exited with status: $EXIT_CODE. Check pidfile and log"
fi
fi
;;
status)
if [ "$PIDFILE" ]; then
PID=`cat $PIDFILE`
OUTPUT=`ps $PID | egrep "^$PID "`
if [ ${#OUTPUT} -gt 0 ]; then
echo "Service running with pid: $PID"
else
echo "Pidfile present, but process not running"
fi
else
echo "No pidfile present"
fi
;;
*)
echo "Unrecognised command. Usage trinidad [ start | stop | restart ]"
;;
esac

If I start trinidad with bundle exec trinidad, everything is ok. I suppose I could do something similar and modify the init.d script, but I think it's important to note that the init.d script that trinidad_init_services creates with these versions is broken by default.