Ruby on rails 即使PassengerPolidleTime为0,乘客进程也会重新启动
我已将PassengerPolidleTime设置为0,希望这意味着我可以“预热”服务器上的一系列passenger进程,并且下次流量激增时(即使是几天后),它们都将被预热并准备好接受请求 相反,我看到的是,每天早上我起床时,Ruby on rails 即使PassengerPolidleTime为0,乘客进程也会重新启动,ruby-on-rails,ruby,passenger,Ruby On Rails,Ruby,Passenger,我已将PassengerPolidleTime设置为0,希望这意味着我可以“预热”服务器上的一系列passenger进程,并且下次流量激增时(即使是几天后),它们都将被预热并准备好接受请求 相反,我看到的是,每天早上我起床时,乘客状态只显示少数几个进程,它们都是从午夜起才开始的。前一天,我对一系列流程进行了预热,最后一次查看乘客状态(午夜前)时,共有50个流程 以下是我的httpd.conf(我在CentOS上)中与乘客相关的全部片段: 我已经检查了root和apache的crontab,看看是
乘客状态
只显示少数几个进程,它们都是从午夜起才开始的。前一天,我对一系列流程进行了预热,最后一次查看乘客状态(午夜前)时,共有50个流程
以下是我的httpd.conf(我在CentOS上)中与乘客相关的全部片段:
我已经检查了root和apache的crontab,看看是否有什么东西触发了apache重启,但我没有看到
下面是一段乘客状态
,大约在午夜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。我发现了发生的事情。这是我的httpd日志文件:
/var/log/httpd/*log {
missingok
notifempty
sharedscripts
postrotate
/sbin/service httpd reload > /dev/null 2>/dev/null || true
endscript
}
是postrotate脚本在执行此操作。重新加载apache会导致乘客进程停止
有人对如何在不重新加载apache的情况下实现这一点有什么好的建议吗?或者是一种在不中断乘客进程的情况下重新加载apache的方法(如果可能的话)?您可以将日志发送到一个程序,该程序根据日期将日志记录到一个文件中,并消除logrotate
CustomLog "|/usr/local/bin/my_log_script" combined
假设lograte是罪魁祸首,我建议使用
copyruncate
功能,而不是在postrotate上重新加载copytruncate
不是原子的,这意味着您可能会丢失几秒钟的日志。您还将短暂地将该日志文件所消耗的磁盘空间增加一倍。一些细节
/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
}
在不重新启动/重新加载服务的情况下进行日志旋转的最简单方法是使用“CopyOnTuncate”选项。这样,logrotate会将日志文件的内容复制到另一个文件,并清空当前日志文件。这样,服务将继续登录到同一个文件,而logrotate将完成它的工作。例如:
/var/log/httpd/*log {
copyontruncate
missingok
notifempty
sharedscripts
}
这是唯一的乘客申请吗?即使设置为0,如果另一个应用程序上需要进程,它们也会关闭。还要检查restart.txt的修改时间,如果有东西碰到它,它会重新启动。是的,它是唯一的乘客应用程序。检查restart.txt是个好主意,但从3月26日起就没有人动过它……你得到答案了吗?
/var/log/httpd/*log {
copyontruncate
missingok
notifempty
sharedscripts
}