Skip to content

Instantly share code, notes, and snippets.

rack_opts = {
:precompilation_enabled => true
}
case ENV["DEPLOY_APPID"]
when "app-production", "app-staging", "app-test01", "app-test02"
ver = ENV["DEPLOY_VERSION"]
raise "DEPLOY_VERSION is blank" if ver.nil? || ver.empty?
rack_opts[:application] = ENV["DEPLOY_APPID"]
$_rack_request_counter = 0
$_rack_rails_app = nil
rails_dispatcher = lambda{|env|
$_rack_request_counter += 1
if $_rack_request_counter <= 1
if env["REQUEST_METHOD"]=="GET"
res = Rack::Response.new("*", 302)
redir_url = env["REQUEST_URI"] + (env["QUERY_STRING"]=="" ? "?" : "&") + "_spinup_=#{Time.now.to_i}"
res["Location"] = redir_url
res.finish
% ruby rails2_td_appengine.rb
=> Bundling gems
Calculating dependencies...
Updating source: http://gems.rubyforge.org
Caching: actionmailer-2.3.5.gem
Caching: actionpack-2.3.5.gem
Caching: activerecord-2.3.5.gem
Caching: activeresource-2.3.5.gem
Caching: activesupport-2.3.5.gem
Caching: appengine-apis-0.0.13.gem

Recently, Takeru Sasaki was able to patch the Rails 2.3.5 calls to rubygems, and now we have it working on App Engine. He also created a datastore adapter called TinyDS. I just created an integration plugin called Rails_TinyDS that provides certain ActiveRecord method calls for Rails 2.3.5 generated scaffold.

See the DataMapper version also: gist.github.com/268192

The gems for the development environment include a pre-release appengine-tools gem that provides a pre-release version of jruby-rack.

sudo gem install google-appengine
#!/usr/bin/ruby
#
# Copyright:: Copyright 2009 Google Inc.
# Original Author:: John Woodell (mailto:woodie@google.com)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0

If we can create a DeferredDispatcher that is safe and generic, spin-up won’t be a show-stopper, and any app can take advantage of it. Adding this to appengine-rack.rb means people won’t need an additional require, but we will be stuck with it.

I have a sample app here: mwrc-demo.appspot.com

When we have app with multiple map sections (see below) that all call the same dispatcher, will the instance variables still work the way we want?

I found this error near "stack level too deep"(=StackOverflowError) error.
This app is build with JRuby+Rails, almost 99.99% is works fine.
This error and "stack level too deep" are very rare case.
public RubyModule popRubyClass() {
int index = parentIndex;
RubyModule[] stack = parentStack;
RubyModule ret = stack[index];
stack[index] = null;
parentIndex = index - 1;
import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse
import javax.servlet.Filter
import java.util.Date
import java.util.ArrayList
import java.net.URL
import java.net.MalformedURLException
import java.io.IOException
import com.google.appengine.api.urlfetch.URLFetchService
import com.google.appengine.api.urlfetch.FetchOptions
tkrmb:~/tmp/src_clones/duby% ../jruby/bin/jruby -S rake compile
(in /Users/takeru/tmp/src_clones/duby)
mkdir -p build
Compiling Ruby sources
Generating Java class DubyCommand to build/org/jruby/duby/DubyCommand.java
javac -d build -cp /Users/takeru/tmp/src_clones/jruby/lib/jruby-complete.jar:. build/org/jruby/duby/DubyCommand.java
/Users/takeru/tmp/src_clones/jruby/lib/ruby/site_ruby/shared/jruby/compiler.rb:142 warning: executable? does not in this environment and will return a dummy value
Compiling Duby sources
org/jruby/duby/ant/compile.duby:2: cannot load Java class org.jruby.duby.DubyCommand
import org.jruby.duby.DubyCommand
import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse
import javax.servlet.Filter
import java.util.Date
import java.util.ArrayList
import java.net.URL
import java.net.MalformedURLException
import java.io.IOException
import com.google.appengine.api.urlfetch.URLFetchService
import com.google.appengine.api.urlfetch.FetchOptions