即使PassengerPoolIdleTime为0,乘客进程也会重新启动

时间:2010-04-08 15:55:47

标签: 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的crontabs,看看是否有触发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。

4 个答案:

答案 0 :(得分:3)

假设lograte是罪魁祸首,我建议使用copytruncate功能而不是在postrotate上重新加载。 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
}

答案 1 :(得分:1)

您可以将日志发送到根据日期记录到文件的程序,并取消logrotate ...

CustomLog "|/usr/local/bin/my_log_script" combined

答案 2 :(得分:0)

我发现了正在发生的事情。这是我的httpd:

的logrotate conf文件
/var/log/httpd/*log {
    missingok
    notifempty
    sharedscripts
    postrotate
        /sbin/service httpd reload > /dev/null 2>/dev/null || true
    endscript
}

这是正在进行的postrotate脚本。重新加载apache会导致乘客进程死亡。

如果没有重新加载apache,任何人都有如何做到这一点的好建议?或者一种方法来重新加载apache而不会消除乘客进程(如果可能的话)?

答案 3 :(得分:0)

在不重新启动/重新加载服务的情况下进行logrotate最简单的方法是使用' copyontruncate'选项。这样logrotate会将日志文件的内容复制到另一个文件,并清空当前的日志文件。这样服务继续记录到同一个文件,logrotate就是这样做的。例如:

/var/log/httpd/*log {
    copyontruncate
    missingok
    notifempty
    sharedscripts
}
相关问题