简体   繁体   中英

how to easily run a sinatra/padrino application on rails hoster

is there an easy way to run a sinatra (in particular a padrino) application "as a" rails app? i guess, there should be some way to translate "rails server" to "padrino start" or something... (the hoster i'm referring too hosts rails with mod_rails.)

If you're using mod_rails (ie. Passenger), you shouldn't have a problem at all - Passenger can host any rack-based app, and I use it for hosting Sinatra, Padrino and Rails apps on my server. A very basic rackup file is all you need for Sinatra, something like:

require 'sinatra_app'
set :run, false
set :environment, ENV['RACK_ENV'] || 'production'
run Sinatra::Application

The basic config.ru file you'll need for a padrino app is even simpler:

require ::File.dirname(__FILE__) + '/config/boot.rb'
run Padrino.application

There's more you can do, like for handling logging, but that should be all you need to get going. Your Apache vhost config for both Sinatra and Padrino apps is also simple, and very similar to what you'd use for Rails, eg.:

<VirtualHost *:80>
  ServerName my.app.com
  DocumentRoot "/var/www/apps/myapp/current/public"
  RackEnv production
</VirtualHost>

That should be all you need to start - the only major difference is that you use RackEnv instead of RailsEnv.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM