ruby-on-rails – 如何在运行时检查我的Rails应用程序是否在开发或生产环境中运行

我正在使用Passenger和Nginx在Centos 6.5服务器上运行rails应用程序.如何在不停止的情况下检查它正在运行的环境?
最佳答案
使用passenger-status命令.例如,这表明我正在运行生产环境(应用程序组标题下的第一行):

(production-web) ubuntu@ip-10-0-3-146 ~% sudo passenger-status                                                              
Version : 5.0.15
Date    : 2015-08-20 17:40:24 +0000
Instance: lNNFwV1C (Apache/2.4.7 (Ubuntu) Phusion_Passenger/5.0.15)

----------- General information -----------
Max pool size : 12
App groups    : 1
Processes     : 6
Requests in top-level queue : 0

----------- Application groups -----------
/home/my-app/deploy/current (production):
  App root: /home/my-app/deploy/current
  Requests in queue: 0
  * PID: 11123   Sessions: 0       Processed: 12997   Uptime: 21h 14m 2s
    CPU: 0%      Memory  : 190M    Last used: 1s ago
  * PID: 11130   Sessions: 0       Processed: 140     Uptime: 21h 14m 2s
    CPU: 0%      Memory  : 153M    Last used: 9m 32s a
  * PID: 11137   Sessions: 0       Processed: 15      Uptime: 21h 14m 2s
    CPU: 0%      Memory  : 103M    Last used: 57m 54s
  * PID: 11146   Sessions: 0       Processed: 6       Uptime: 21h 14m 2s
    CPU: 0%      Memory  : 101M    Last used: 7h 47m 4
  * PID: 11153   Sessions: 0       Processed: 5       Uptime: 21h 14m 1s
    CPU: 0%      Memory  : 100M    Last used: 8h 42m 3
  * PID: 11160   Sessions: 0       Processed: 2       Uptime: 21h 14m 1s
    CPU: 0%      Memory  : 81M     Last used: 8h 42m 3

rails console不可靠 – 它只告诉您运行控制台的环境.可以将乘客配置为在不同的环境中运行.

转载注明原文:ruby-on-rails – 如何在运行时检查我的Rails应用程序是否在开发或生产环境中运行 - 代码日志