1

I have started writing my Sinatra apps using a modular style, suggested in this stackoverflow answer, and have successfully deployed it on Heroku, but when trying to deploy to AppFog (identical code except for datamapper mysql/postgres gems) I get "Not Found" errors for every route I have defined.

== Sinatra/1.3.3 has taken the stage on 47195 for production with backup from Thin
myIP, 127.0.0.1 - - [08/Dec/2012 21:28:53] "GET / HTTP/1.0" 404 18 0.0030
myIP, 127.0.0.1 - - [08/Dec/2012 21:28:54] "GET /any_route HTTP/1.0" 404 18 0.0010
myIP, 127.0.0.1 - - [08/Dec/2012 21:28:58] "GET /about HTTP/1.0" 404 18 0.0008

My view and public paths from settings:

settings.views = "./views"
root = "."
settings.sin_auth_view_path =  "/mnt/var/vcap.local/dea/apps/myapp-0-d1d1d1dc0e543b1759afda27b/app/views/"
public_folder = "./public"

An example of defined route:

class MyApp < Sinatra::Application
  get '/' do
    @title = "Site Index Page"

    haml :index
  end
end

Config.ru

require ::File.join( ::File.dirname(__FILE__), 'app')

run MyApp.new

Structure is basically identical to that linked to above.

There are no application errors, just the "Not Found" message and corresponding 404 "GET" entries in the logs. The PUBLIC folder is working as it should - I can access all static files off the site url (ie. site.com/img/anypic.jpg). And, as I mentioned, the exact same app runs flawlessly on Heroku.

I am using bundle package, so a custom gem can be used, and had no problems until switching to the modular structure.

Installed on AppFog Ruby 1.9.3 Runtime.

Thoughts....

Community
  • 1
  • 1
Gus Shortz
  • 1,711
  • 1
  • 15
  • 24

2 Answers2

1

Thanks to a user on the AppFog Google User Group, the solution was to deploy as a Rack application instead of a Sinatra application.

Note: Also make sure to use the --runtime ruby193 command line option, if you are using require_relative :)

Gus Shortz
  • 1,711
  • 1
  • 15
  • 24
0

I would check to see if you might be having a problem with the "settings.sin_auth_view_path" entry as it's an absolute path (whereas the other two are relative). Heroku does not have the normal filesystem layout that you're used to seeing on a development box once you ascend outside your app's source.

mjbraun
  • 117
  • 5
  • If Heroku doesn't have a normal filesystem layout, why does it work there AND on my local system then? The problem is it doesn't work on AppFog. But I will try changing the "settings.sin_auth_view_path" to a relative one, and see if that makes a difference ... and report back. Thanks. I may also try installing directly on an AWS EC2 instance (Bitnami Ruby 193 AMI), to see how that goes. – Gus Shortz Dec 12 '12 at 08:00
  • could you point me to an explanation of the Heroku file system differences? Thanks. – Gus Shortz Dec 13 '12 at 18:19
  • See [this](https://devcenter.heroku.com/articles/dynos#ephemeral-filesystem). It's not super descriptive, but basically local files can go away at any moment and you can't access outside your app source tree. – mjbraun Dec 13 '12 at 18:48