Skip to content

Instantly share code, notes, and snippets.

View syntaxritual's full-sized avatar

Travis Anderson syntaxritual

View GitHub Profile
user app;
worker_processes 2;
error_log /home/app/logs/nginx.error.log info;
events {
worker_connections 1024;
}
# Deploying a Sinatra app to Heroku
## Database
The location of the database Heroku provides can be found in the environment
variable DATABASE_URL. Check the configure-block of toodeloo.rb for an example
on how to use this.
## Server
Heroku is serving your apps with thin, with means you have all your thin goodness available,
such as EventMachine.
def partial(template, locals={})
haml("_#{template}".to_sym, :locals => locals, :layout => false)
end
def errors_on(object, field)
return "" unless errors = object.errors.on(field)
errors.map {|e| e.gsub(/#{field} /i, "") }.join(", ")
end
def error_class(object, field)
## Pseudo auto-respond-to in Sinatra.
module Sinatra
module AutoRespondTo
def self.registered(app)
app.after do
case request.accept.first
when "application/json"
body { body.to_json }
when "application/xml"
require 'rubygems'
require 'eventmachine'
require 'socket'
module RPCServer
include EM::P::ObjectProtocol
def post_init
@obj = Hash.new
end
def receive_object method
require 'rubygems'
require 'eventmachine'
require 'socket'
module RPCServer
include EM::P::ObjectProtocol
def post_init
@obj = Hash.new
end
def receive_object method
user nginx;
worker_processes 5;
error_log /var/log/nginx.error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}