1

在生产服务器上,Passenger(4.0.0.rc6 + nginx) 不断要求:development. Gemfile从应用程序中手动将它们注释掉后Gemfile运行良好。否则,Passenger 会因为缺少宝石而无法启动应用程序。

我检查了错误页面,似乎Passenger在生产模式下运行:

Environment (value of RAILS_ENV, RACK_ENV, WSGI_ENV and PASSENGER_ENV)
production

以下是我的简单应用程序的来源,我是否缺少让乘客工作的任何设置?谢谢。

这是我的app.rb,一个简单的 sinatra 应用程序。

require 'rubygems'
require 'sinatra'
get "/" do
   "Hello!"
end

我通过 vlad 将它部署到生产服务器。这里是config/deploy.rb

require 'bundler/vlad'
set :application, "sinatratest"
set :domain, "server domain"
set :deploy_to, "path/on/server"
set :repository, "mygithub branch"

和我的config.ru

require 'rubygems'
require 'sinatra'
require './app'
run Sinatra::Application

Gemfile

source 'https://rubygems.org'
gem 'sinatra'
group :development do
    gem 'vlad', require: false
    gem 'vlad-git', require: false
end
4

2 回答 2

2

回答我自己的问题:

请参阅Bundler 手册中的 vlad 部分,require 'bundler/vlad'并创建一个新任务,该任务同时运行vlad:updatevlad:bundle:install或插入vlad:bundle:install原始vlad:update命令。

如果服务器使用 RVM,那么它需要在 vlad 任务中bundle显式设置路径source ~/.rvm/scripts/rvm或使用vlad-extragem,请参阅这篇文章

我正在做什么以使其发挥作用:

config/deploy.rb

require 'bundler/vlad'
set :bundle_cmd, "source $HOME/.rvm/scripts/rvm && bundle" 

Rakefile

namespace :vlad do
  desc "Run vlad:update and vlad:bundle:install"
  task :deploy => %w[vlad:update vlad:bundle:install]
end

在本地机器上运行rake vlad:deploy,它可以工作。

于 2013-04-18T16:40:19.227 回答
0

我认为问题是

需要“红宝石”

据我了解,这意味着需要 Gemfile 中的所有宝石。只需要具有以下功能的 Productiv 宝石:

require 'rubygems'
require 'bundler/setup'

来源: http: //gembundler.com/v1.3/rationale.html

于 2013-04-18T08:45:55.670 回答