June 4th, 2008 cschneid
It’s nice having a chat channel as dead as #sinatra. It makes it trivial to go back through a day and read every message that went through. One of those messages yesterday was from SirSydAlot asking if Sinatra could bind to a certain IP address. I told him at the time that Rack should support it, but Sinatra didn’t yet, so I went to check that fact.
in Rack::Handler::Mongrel
server = ::Mongrel::HttpServer.new(options[:Host] || '0.0.0.0',
options[:Port] || 8080)
and in Rack::Handler::Thin
server = ::Thin::Server.new(options[:Host] || '0.0.0.0',
options[:Port] || 8080,
app)
So I made a patch to add a host option
. It’s pretty simple to use:
# That's it...
set :host, '192.168.1.1'
It sounds like the patch will be included in the mainline code soon, so look for that. Until then, be sure to use my host_setting branch, as that’s the only place this patch is.
Posted in Programming, Sinatra | No Comments »
June 3rd, 2008 cschneid
In my never ending quest to avoid doing anything useful, I decided to attempt to run Sinatra on top of JRuby. I had the original goal of getting it to run under JRuby-Rack and built into a war file that Tomcat or JBoss, or Weblogic, or… Glassfish(??) would take. Unfortunately, I didn’t get that far. What I saw was:
LocalJumpError - yield called out of block
My mini application that shows the issue:
$:.unshift File.dirname(__FILE__) + '/sinatra/lib'
require 'sinatra'
get '/' do
"Hello World"
end
get '/no_layout' do
erb :foo, :layout => false
end
get '/erb' do
erb :foo
end
get '/haml' do
haml :foo
end
Of course I have some views: - (just erb here, hamls are almost identical)
<!-- this is foo.erb -->
<p>Erb rendered</p>
<!-- this is layout.erb -->
<html>
<head></head>
<body>
<p>Layout rendered</p>
<%= yield %>
</body>
</html>
So… I filed a bug report against JRuby.. I’m impressed that Vladimir has already identified the narrow test case that I didn’t, and has written specs. I’m hoping that the next release of JRuby will have this fixed, and we can all move on with our lives.
Until then, layouts in Sinatra don’t work with JRuby.
Posted in Programming, Ruby, Sinatra | No Comments »
June 1st, 2008 cschneid
According to this post it looks like the version 2 release of Passenger will support Rack. Since Sinatra is built right on top of Rack, that means that Passenger will support Sinatra.
In practical terms, that means whenever Dreamhost (and other shared hosting providers) gets around to updating their Passenger installations, deployment of Sinatra apps will be as easy as writing a rackup file.
UPDATE: Sure enough, the newest release supports Rack, and I have a tutorial on getting sintra deployed on Dreamhost via passenger/mod_rails.
Posted in Programming, Ruby, Sinatra | No Comments »