我有一个在ubuntu 14.04机器上运行的rails应用程序,它由Nginx和乘客提供服务.有时候应用程序出现故障会出现以下错误
[ agents/LoggingAgent/Main.cpp:338 ]: Signal received. Gracefully shutting down... (send signal 2 more time(s) to force shutdown)
[ agents/LoggingAgent/Main.cpp:400 ]: Received command to shutdown gracefully. Waiting until all clients have disconnected...
[ ServerKit/Server.h:453 ]: [LoggerAdminServer] Shutdown finished
[ agents/LoggingAgent/Main.cpp:425 ]: PassengerAgent logger shutdown finished
[ ServerKit/Server.h:453 ]: [ServerThr.1] Shutdown finished
[ ServerKit/Server.h:453 ]: [ServerThr.2] Shutdown finished
[ ServerKit/Server.h:453 ]: [AdminServer] Shutdown finished
[ agents/HelperAgent/Main.cpp:724 ]: disconnecting long-running connections for process 19431,application /public#default
[ agents/HelperAgent/Main.cpp:724 ]: disconnecting long-running connections for process 19440,application /public#default
[ agents/Watchdog/Main.cpp:1255 ]: Starting PassengerAgent watchdog...
[ agents/HelperAgent/Main.cpp:883 ]: Starting PassengerAgent server...
[ agents/HelperAgent/Main.cpp:232 ]: PassengerAgent server running in multi-application mode.
[ agents/HelperAgent/Main.cpp:637 ]: PassengerAgent server online,PID 19637
[ agents/LoggingAgent/Main.cpp:431 ]: Starting PassengerAgent logger...
[ agents/LoggingAgent/Main.cpp:312 ]: PassengerAgent logger online,PID 19645
[ agents/HelperAgent/Main.cpp:868 ]: PassengerAgent server shutdown finished
除非Nginx正在重新启动,否则应用程序将保持关闭状态.这可能是由于陈旧的工人不再服务而且吃掉了记忆(如果我错了,请纠正我).
我已将乘客的最大池大小设置为6,因为我的应用实例需要150-200 Mb的内存和2GB RAM.
我正在考虑编写一个脚本,定期检查陈旧的工作人员,如果发现重新启动Nginx或触摸tmp / restart.txt.我也想知道如何检查陈旧的工人或乘客是否按预期工作.
我认为另一种解决方案是定期重启Nginx或在一段时间后定时触摸tmp / restart.txt,比如说一小时.
我还阅读了有关重启应用程序的三种方法的乘客文档
> passenger-config restart-app
> restart.txt
>重启Nginx
前两个案例在重新启动应用程序时不会丢弃任何请求,但在重新启动应用程序时可能没有停机时间,因为重新启动应用程序可能需要一些时间,具体取决于应用程序.
我想知道哪个是好方法,还是有其他办法摆脱这个问题.
最佳答案
首先,你应该真的检查passenger configuration options.其次,你应该弄清楚你的乘客工人究竟挂了什么.为此,有一个乘客日志参数(您可以监控),因为您似乎并不确定这些流程中发生了什么.