Skip to content

Instantly share code, notes, and snippets.

@casualjim
Created January 12, 2011 07:12
Show Gist options
  • Save casualjim/775801 to your computer and use it in GitHub Desktop.
Save casualjim/775801 to your computer and use it in GitHub Desktop.
A jruby jetty launcher for an exploded war
description "ConnFu demo application"
start on runlevel [2345]
stop on runlevel [!2345]
console none
# the following ensures that the process is restarted when it should die unexpectedly
respawn
exec sudo -u randomuser -H bash -c "cd /home/randomuser/connfu-demo; PORT=14080 /home/randomuser/.rvm/rubies/jruby-1.5.6/bin/ruby -J-Xmx256m -J-Xms128m -J-Xmn64m --server --headless connfu-demo-server"
#!/path/to/jruby -J-Xmx256m -J-Xms128m -J-Xmn64m --server --headless
include Java
import java.lang.System
PORT = ENV["PORT"] || 8888
WEB_PATH = ENV['WEB_PATH'] || File.expand_path("..", __FILE__)
System.set_property("logback.configurationFile", "#{WEB_PATH}/WEB-INF/classes/logback.xml")
Dir["#{WEB_PATH}/WEB-INF/lib/*.jar"].each { |d| require d }
$CLASSPATH << "#{WEB_PATH}/WEB-INF/classes"
import org.eclipse.jetty.server.Server
import org.eclipse.jetty.webapp.WebAppContext
server = Server.new(PORT.to_i)
server.set_graceful_shutdown 5000
context = WebAppContext.new
context.set_descriptor "#{WEB_PATH}/WEB-INF/web.xml"
context.set_resource_base WEB_PATH
context.set_context_path "/"
server.set_handler context
puts "Starting jetty in #{WEB_PATH} on #{PORT}"
server.start
server.join
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment