Deploying the Sinatra app on Dreamhost / Passenger with custom gems

I have a Sinatra application that I am trying to run on Dreamhost, which uses a pony to send email. To the application was launched and started at the beginning (before the addition of a pony), I had to gem unpack rackand gem unpack sinatrathe directory vendor /, so this was my config.ru:

require 'vendor/rack/lib/rack'
require 'vendor/sinatra/lib/sinatra'

set :run, false
set :environment, :production
set :views, "views"

require 'public/myapp.rb'
run Sinatra::Application

I have already done gem install ponyand gem unpack pony(in vendor /). Subsequently, I tried to add require 'vendor/sinatra/lib/pony'to config.ru only so that the Passenger complains about pony dependencies (mime-types, tmail) that were not found!

There are , in order to better use other gems and soften these long, ugly, excess ones requires. Any thoughts?

+3
4

"-", config.ru :

ENV['GEM_PATH'] = xxx
Gem.clear_paths

+4

Ruby gems dreamhost

http://c.kat.pe/post/installing-ruby-gems-on-dreamhost/

config.ru( Sinatra 1.0)

"rubygems"

require 'vendor/sinatra/lib/sinatra.rb'

ENV['GEM_HOME'] = '/home/username/.gems'
ENV['GEM_PATH'] = '$GEM_HOME:/usr/lib/ruby/gems/1.8'
require 'rubygems'
Gem.clear_paths

disable :run, :reload

set :environment, :production

require 'yourapp'
run Sinatra::Application

, -.

. . (GEM_HOME GEM_PATH), .

+3

, , "gem install sinatra", gem ( ), gem. , , - . $HOME/.gem , . "/". , $HOME/.gem/ruby ​​/1.8/bin , , .

config.ru( Dreamhost)

## Passenger should set RACK_ENV for Sinatra
require 'test'
set :environment, :development
run Sinatra::Application

Later editing: all is well and good, but the problem remains that the Passenger cannot find my gems when the task is initially launched .

+1
source

My config.ru is just simple:

require 'rubygems'
require 'vendor/sinatra/lib/sinatra.rb'
require 'app.rb'

and app.rb head:

require 'yaml'
require 'haml'
require 'ostruct'
require 'date'
require 'pp'

module FlytoFB
    log = File.new("sinatra.log", "a")
    STDOUT.reopen(log)
    STDERR.reopen(log)

    configure do

            enable :logging, :dump_errors
            set :app_file, __FILE__
            set :reload, true
            set :root, File.dirname(__FILE__)
            set :environment, :production
            set :env, :production
            set :run, false

            set :raise_errors, true
      set :public, 'public'

            error do
                    e = request.env['sinatra.error']
                    puts e.to_s
                    puts e.backtrace.join("\n")
                    "Application Error!"
            end

            not_found do
              "Page not found!"
      end
0
source

Source: https://habr.com/ru/post/1724445/


All Articles