【问题标题】:How to restart Phusion Passenger + Apache in Production mode on Ubuntu server for Ruby on Rails?如何在 Ubuntu 服务器上为 Ruby on Rails 以生产模式重新启动 Phusion Passenger + Apache?
【发布时间】:2013-03-12 17:51:00
【问题描述】:

我有 Apache + phusion 乘客,我已经放了

RailsEnv production

在 /etc/apache2/sites-available/default 文件中并已重新启动 apache 但当我运行时

rails c
> Rails.env.production?

它给出了假象

> Rails.env.development?

它给出了真实的。有没有其他方法可以重新启动乘客,因为我认为默认设置“RailsEnv 生产”是正确的方法?顺便说一句,我正在使用

sudo service apache2 restart

如何在生产模式下使用乘客 + apache 启动我的 ruby​​ on rails 应用程序?

【问题讨论】:

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


    【解决方案1】:

    只需在应用的 tmp 目录中创建一个 restart.txt

    例如

      touch %RAILS_ROOT%/tmp/restart.txt
    

    看这里 http://www.modrails.com/documentation/Users%20guide%20Apache.html 3.3 节

    【讨论】:

    • 我如何确定这会产生效果(我正在重新组织我的 phusion/capistrano 设置)?或者,这个“重启”到底是为了什么?
    • 啊!我可以通过查看 Apache 错误日志文件(在我的情况下为 /var/log/apache2/error.log)来告诉它重新启动:[ 2014-01-08 20:37:38.9069 32489/7ff921f67700 Pool2/SmartSpawner.h :301 ]: /app01/akiary_registration/app 的预加载器在 PID 13325 上启动,监听 unix:/tmp/passenger.1.0.32480/generation-0/backends/preloader.13325
    【解决方案2】:

    您的应用可能已经处于生产模式。

    默认情况下,rails c 在开发模式下加载应用程序。

    如果您希望控制台以生产模式启动,请执行以下操作:

    RAILS_ENV=production rails c

    控制台和 Web 应用程序是两个不同的 Rails 进程并独立运行。

    您应该检查您的 production.log 文件以确保您的应用在生产中运行。

    【讨论】:

    • 你是对的,development.rb 只有 4 个条目,但 production.rb 已满,所以服务器肯定在生产模式下运行。
    • 你也可以通过输入'rails console [environment]'来做到这一点,例如rails 控制台制作
    【解决方案3】:

    仅用于启动具有特定端口的应用程序,请使用以下命令:

    乘客启动 -a 0.0.0.0 -p 3000 -d -e 生产

    【讨论】:

      【解决方案4】:

      我按照 PhusionPassenger 文档here 中列出的命令进行操作,它们立即生效。

      deployer@staging:~$ passenger-config restart-app
      Please select the application to restart.
      Tip: re-run this command with --help to learn how to automate it.
      If the menu doesn't display correctly, press '!'
      
       ‣   /home/deployer/myapp/current (staging)
           /home/deployer/myapp_2/current (staging)
           Cancel
      
      Restarting /home/deployer/myapp/current (staging)
      
      deployer@staging:~$ passenger-config restart-app
      Please select the application to restart.
      Tip: re-run this command with --help to learn how to automate it.
      If the menu doesn't display correctly, press '!'
      
           /home/deployer/myapp/current (staging)
       ‣   /home/deployer/myapp_2/current (staging)
           Cancel
      
      Restarting /home/deployer/myapp_2/current (staging)
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-10-16
        • 2011-03-11
        • 2015-08-31
        • 1970-01-01
        • 2014-10-19
        • 2016-05-31
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多