You are currently browsing the tag archive for the ‘Sinatra’ tag.

Writes to console and outputs to log…

error_logger = Logger.new('log/errors.log')
error do
  e = request.env['sinatra.error']
  info = "Application error\n#{e}\n#{e.backtrace.join("\n")}"

  error_logger.info info
  Kernel.puts info

  'Application error'
end

Just wanted to share our setup, as reminder and help for others ;)

(do not forget to create a tmp and public folder inside your projects folder)

#/opt/nginx/conf/nginx.conf
server {
  listen 80;
  server_name xxx.yyy.com;

  access_log /var/log/xxx_access.log  main;
  error_log /var/log/xxx_error.log debug;
  root /srv/xxx/public;   # <--- be sure to point to 'public'!
  passenger_use_global_queue on;
}

#/etc/hosts
127.0.0.1       xxx.yyy.com

#config.ru
require 'app'
disable :run
set :root, Pathname(__FILE__).dirname
run Sinatra::Application

#app.rb
require 'rubygems'
require 'sinatra'

get "/" do
  "Hello world from xxx"
end
Follow

Get every new post delivered to your Inbox.

Join 63 other followers