【问题标题】:How to use Phusion Passenger Standalone as the default Rails server如何使用 Phusion Passenger Standalone 作为默认 Rails 服务器
【发布时间】:2013-10-29 20:44:27
【问题描述】:

由于我的 Rails 应用程序中有一些花哨的技巧(并且为了让我的开发设置看起来更像产品),我开始使用 Phusion Passenger Standalone 作为我的开发 Web 服务器。

目前我以$ bundle exec passenger start 开头。如果我运行 $ rails s 它会启动 WEBrick,这不是我想要的。

有没有办法配置我的应用,以便我可以像 $ rails s 一样以“常规方式”运行它?

(对不起,如果这很明显,在谷歌上搜索预期的关键字会发现很多不相关的东西......)

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-3 passenger


    【解决方案1】:

    如果您真的想强制执行此操作,那么有一个简单的 hack 可以完全按照您的意愿进行操作。 您可以修改应用程序的脚本/rails 以捕获所有 rails 服务器调用并进行系统调用以启动乘客,如下所示:

    if (ARGV.first == 'server' || ARGV.first == 's')
      system("passenger start #{ARGV.shift.join(" ")}")
    else
      # The old content of the script goes here
      APP_PATH = File.expand_path('../../config/application',  __FILE__)
      require File.expand_path('../../config/boot',  __FILE__)
      require 'rails/commands'
    end
    

    更多信息请点击此处https://groups.google.com/forum/#!topic/phusion-passenger/XBhlF5lRo2A

    【讨论】:

    • 感谢您的回答!但有一个建议:我最终使用了ARGV.drop(1),而不是ARGV.shift,以便将除第一个参数之外的所有参数传递给乘客。
    猜你喜欢
    • 1970-01-01
    • 2010-10-25
    • 1970-01-01
    • 1970-01-01
    • 2014-10-19
    • 2012-10-16
    • 2016-03-02
    • 1970-01-01
    • 2020-07-02
    相关资源
    最近更新 更多