ruby-on-rails - 即使 PassengerPoolIdleTime 为 0,Passenger 进程也会重新启动

标签 ruby-on-rails ruby passenger

我已将 PassengerPoolIdleTime 设置为 0,期望这意味着我可以在我的服务器上“预热”一堆乘客进程,并且下次我遇到突发流量时(即使是几天后),他们都会热身并准备好接受请求。

相反,我看到的是每天早上起床时,passenger-status 只显示少数几个进程,而且它们都是从午夜开始才启动的。前一天我预热了一堆进程,最后一次查看 passenger-status(午夜前)有 50 个进程。

这是我的 httpd.conf 中与 Passenger 相关的完整片段(我在 CentOS 上):

LoadModule passenger_module /usr/local/lib/ruby/gems/1.8/gems/passenger 2.2.11/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.11
PassengerRuby /usr/local/bin/ruby
PassengerMaxPoolSize 60
PassengerPoolIdleTime 0

我已经检查了 root 和 apache 的 crontab,看看是否有什么东西触发了 apache 重启,但我没有看到它。

这是 passenger-status 的片段,大约在午夜后 11 小时 46 分钟:

----------- General information -----------
max      = 60
count    = 3
active   = 0
inactive = 3
Waiting on global queue: 0

----------- Domains -----------
/var/www/myapp/current: 
  PID: 20704   Sessions: 0    Processed: 360     Uptime: 11h 44m 16s
  PID: 20706   Sessions: 0    Processed: 4249    Uptime: 11h 44m 9s
  PID: 20708   Sessions: 0    Processed: 14189   Uptime: 11h 44m 9s

下面是我执行 ps aux | 时看到的内容grep apache:

apache   13297  0.0  0.0 546652  5312 ?        Sl   14:28   0:00 /usr/sbin/httpd.worker
apache   13332  0.0  0.0 546652  5336 ?        Sl   14:28   0:00 /usr/sbin/httpd.worker
apache   13334  0.0  0.0 546652  5328 ?        Sl   14:28   0:00 /usr/sbin/httpd.worker
root     16841  0.0  0.0   6004   628 pts/0    S+   15:48   0:00 grep apache
root     20478  0.0  0.0  88724  3640 ?        Sl   04:02   0:01 /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.11/ext/apache2/ApplicationPoolServerExecutable 0 /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.11/bin/passenger-spawn-server /usr/local/bin/ruby  /tmp/passenger.30916
apache   20704  0.0  1.7 251080 135164 ?       S    04:02   0:06 Rails: /var/www/apps/myapp/current                                                                                                                                                
apache   20706  0.2  1.7 255188 137704 ?       S    04:02   1:52 Rails: /var/www/apps/myapp/current                                                                                                                                                
apache   20708  0.9  1.7 255180 139332 ?       S    04:02   6:26 Rails: /var/www/apps/myapp/current

服务器使用 UTC,因此 04:02 对应于我的时间 (EDT) 中午 12:02。

最佳答案

假设 lograte 是罪魁祸首,我建议使用 copytruncate 功能而不是在旋转后重新加载。 copytruncate 不是原子的,这意味着您可能会丢失几秒钟的日志。您还将短暂地使该日志文件占用的磁盘空间增加一倍。 Here's一些细节。

/var/log/apache2/*.log {
  weekly
  missingok
  rotate 52
  compress
  delaycompress
  notifempty
  create 640 root adm
  sharedscripts
  copytruncate
  #postrotate
  # /etc/init.d/apache2 reload > /dev/null
  endscript
}

关于ruby-on-rails - 即使 PassengerPoolIdleTime 为 0,Passenger 进程也会重新启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2601401/

相关文章:

ruby-on-rails - Errno::ECONNRESET:Rails 中的对等方使用 rest-client 重置连接

html - 在 rails 3 的 iframe 中呈现部分内容

ruby-on-rails - Ruby 数组到 JSON 和 Rails JSON 渲染

html - 去除按钮的阴影

ruby - 无限 ruby 纤维?

ruby - Ruby each 方法由什么组成?

ruby - 如何在 Ruby 中要求一个 block ?

ruby-on-rails - 错误的 URI(不是 URI?)在 ubuntu 终端中运行 rails 时

Centos 6.4 - 无法从共享对象 : Permission denied 映射段

ruby-on-rails - Nginx 和 Passenger 用户权限。最佳实践?