Skip to content

Instantly share code, notes, and snippets.

@jkutner
Created March 30, 2012 19:12
Show Gist options
  • Save jkutner/2254164 to your computer and use it in GitHub Desktop.
Save jkutner/2254164 to your computer and use it in GitHub Desktop.
Deploying Two Applications to One Trinidad Server
require 'rubygems'
require 'sinatra'
require 'active_record'
get '/' do
ActiveRecord::Base.establish_connection(
:adapter => "jdbcpostgresql",
:jndi => "java:/comp/env/jdbc/trinidad"
)
r = ActiveRecord::Base.connection.execute(
"select count(*) from pg_catalog.pg_tablespace")
"Thing one found: #{r.inspect}"
end
run Sinatra::Application
$ trinidad --config /opt/trinidad/trinidad.yml
Mar 29, 2012 11:46:52 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-3000"]
Mar 29, 2012 11:46:52 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Tomcat
Mar 29, 2012 11:46:52 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.23
2012-03-30 04:46:52 INFO: No global web.xml found
2012-03-30 04:46:53 INFO: jruby 1.6.7 (ruby-1.8.7-p357) (2012-02-22 3e82bc8) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_29) [darwin-x86_64-java]
2012-03-30 04:46:56 INFO: The start() method was called on component [Realm[Simple]] after start() had already been called. The second call will be ignored.
2012-03-30 04:46:56 INFO: jruby 1.6.7 (ruby-1.8.7-p357) (2012-02-22 3e82bc8) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_29) [darwin-x86_64-java]
2012-03-30 04:46:58 INFO: Starting ProtocolHandler ["http-bio-3000"]
require 'rubygems'
require 'sinatra'
get '/' do
"This is thing one!"
end
run Sinatra::Application
require 'rubygems'
require 'sinatra'
get '/' do
"This is thing two!"
end
run Sinatra::Application
web_apps:
default: # use the "/" context
web_app_dir: '/opt/trinidad/thing1'
thing2: # use the "/thing2" context
web_app_dir: '/opt/trinidad/thing2'
web_apps:
default:
web_app_dir: '/opt/trinidad/thing1'
thing2:
web_app_dir: '/opt/trinidad/thing2'
extensions:
postgresql_dbpool:
jndi: 'jdbc/trinidad'
username: 'postgres'
password: 'Passw0rd'
url: 'jdbc:postgresql://localhost:5432/trinidad'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment