开发者

Sinatra App 404 Error In Production Mode

开发者 https://www.devze.com 2023-04-13 04:36 出处:网络
My productions setup\'s as follows: Ubuntu 10.10 rails 3.1.1 Passenger 3.0.9 Sinatra 1.3.1 Apache 2.2.17 I have tested my app on my development machine without issue but when I deploy to my produc

My productions setup's as follows:

  • Ubuntu 10.10
  • rails 3.1.1
  • Passenger 3.0.9
  • Sinatra 1.3.1
  • Apache 2.2.17

I have tested my app on my development machine without issue but when I deploy to my production server, I get a Page Not Found error displayed (not the usual apache one).

I can run using rackup config.ru without issue so assume it has to be an apache / passenger problem, and maybe path related. I have now tired on two different servers, both giving the same error.

My config.ru file is as follows:

require 'rubygems'
require 'sinatra'

use Rack::ShowExceptions

#set :public_folder, File.expand_path(File.dirname(__FILE__) + "/public")
#set :views, File.expand_path(File.dirname(__FILE__) + "/views")

root_dir = File.dirname(__FILE__)
set :root,        root_dir
disable :run

FileUtils.mkdir_p 'log' unless File.exists?('log')
log = File.new("log/sinatra.lo开发者_高级运维g", "a")
$stdout.reopen(log)
$stderr.reopen(log)

#use Rack::ShowExceptions

require File.dirname(__FILE__) + "/bin/hsloginapp"
run Sinatra::Application

My virtual host file:

<VirtualHost *:4090>
    ServerName sinatra-demo.xxxxxxx.net
    DocumentRoot "/var/www/html/hsloginapp/production/current/public"
    <Directory /var/www/html/hsloginapp/public>
        Order allow,deny
        Allow from all
        Options FollowSymLinks
    </Directory>
</VirtualHost>

My app's a bit too complicated to paste all here but am happy to paste parts if required.

I have no issues with a simple sinatra app and therefore feel as though things are running OK. Have now spent four days on this - it's driving me crackers.

Can't really even see where this 404 is coming from. All I can see in my sinatra.log is:

[16/Oct/2011 20:55:41] "GET / " 404 18 0.0008

I don't have an index file in my public folder - although I don't have one in an of my other passenger / rails apps...

Any suggestions greatly appreciated!!

-- UPDATE --

Thinking my apache config might have been stuffed, I installed nginx and get the same Not Found page. Which doesn't seem to exist anywhere in my file system.

Looking through my sinatra log, it looks like webrick's starting - I have no idea why though?

2011-10-22 15:13:12] INFO  WEBrick 1.3.1
[2011-10-22 15:13:12] INFO  ruby 1.8.7 (2010-08-16) [x86_64-linux]
[2011-10-22 15:13:17] WARN  TCPServer Error: Address already in use - bind(2)
== Someone is already performing on port 4990!
94.194.200.254 - - [22/Oct/2011 15:13:17] "GET / " 404 18 0.0636
94.194.200.254 - - [22/Oct/2011 15:13:18] "GET /favicon.ico " 404 18 0.0012

I guess that's the issue?! Help needed :)

-- UPDATE 2 --

Just noticed in my nginx error log that the system's trying to load public/index.html

*9 "/var/www/html/hotspotlogin/public/index.html" is not found (2: No such file or directory)

Shouldn't passenger / nginx know what to do here??!


The issue is probably that you don't have passenger set up properly.

On Apache, make sure you have this line somewhere:

LoadModule passenger_module /somewhere/passenger-x.x.x/ext/apache2/mod_passenger.so

On nginx, your config should include this line:

passenger_enabled on;

Note that you are trying to run Sinatra with WEBRick, not with Rassenger/Apache in the logs example up there (and that port is not available). For running it with Passenger, you will have to write a config.ru, since Passenger doesn't know a thing about Sinatra.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号