crafterm / guitarzero

Guitarzero is a high score management web application for Guitar Hero!

This URL has Read+Write access

guitarzero / rv_harness.rb
100755 43 lines (34 sloc) 1.232 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Example mongrel harness for camping apps with rv
#
# author: Evan Weaver
# url: http://blog.evanweaver.com/articles/2006/12/19/rv-a-tool-for-luxurious-camping
# license: AFL 3.0
 
require 'rubygems'
require 'mongrel'
require 'mongrel/camping'
LOGFILE = 'mongrel.log'
PIDFILE = 'mongrel.pid'
 
# or whatever else you want passed in
PORT = ARGV[0].to_i
ADDR = ARGV[1]
 
# this is your camping app
require 'guitarzero'
app = Guitarzero
 
# custom database configuration
app::Models::Base.establish_connection(:adapter => "sqlite3", :dbfile => "/var/www-apps/guitarzero/guitarzero.db")
 
app::Models::Base.logger = Logger.new(LOGFILE) # comment me out if you don't want to log
app::Models::Base.threaded_connections=false
app.create
 
config = Mongrel::Configurator.new :host => ADDR, :pid_file => PIDFILE do
  listener :port => PORT do
    uri '/', :handler => Mongrel::Camping::CampingHandler.new(app)
    # use the mongrel static server in production instead of the camping controller
    uri '/static/', :handler => Mongrel::DirHandler.new("static/")
    uri '/favicon.ico', :handler => Mongrel::Error404Handler.new('')
    setup_signals
    run
    write_pid_file
    log "#{app} available at #{ADDR}:#{PORT}"
    join
  end
end