Phusion Passenger:使用 OOB 工作退出进程

Phusion Passenger: Using OOB work to exit a process

Phusion Passenger 版本:5.0.29

我已阅读有关 Passenger's OOB (Out-of-Band) 功能的文档,并想使用它来带外决定进程是否应该退出。如果进程必须退出,那么在 OOB 工作结束时,进程调用 raise SystemExit

我们已经设法让这个在进程退出的地方工作,然后 Passenger 稍后启动一个新进程来处理新的传入请求。但是,我们偶尔会在乘客日志中看到带有以下行的 502。

[ 2019-03-27 22:25:13.3855 31726/7f78b6c02700 age/Cor/Con/InternalUtils.cpp:112 ]: [Client 1-10] Sending
502 response: application did not send a complete response
[ 2019-03-27 22:25:13.3859 31726/7f78b6201700 age/Cor/CoreMain.cpp:819 ]: Checking whether to disconnect
long-running connections for process 10334, application agent
App 16402 stdout:
App 16441 stdout:
App 16464 stdout:
[ 2019-03-27 22:28:05.0320 31726/7f78ba9ff700 age/Cor/App/Poo/AnalyticsCollection.cpp:102 ]: Process (pid=16365, group=agent) no longer exists! Detaching it from the pool.

上述行为是由于请求处理程序将请求转发给进程和进程退出之间的竞争条件造成的吗? Passenger 是为处理这种情况而设计的吗?此问题的任何解决方法/解决方案?

谢谢!

看起来我们需要运行“passenger-config detach-process [PID]”以正常终止。

Improved process termination mechanism

If you wish to terminate a specific application process -- maybe because it's misbehaving -- then you can do that simply by killing it with the kill command. Unfortunately this method has a few drawbacks:

Any requests which the process was handling will be forcefully aborted, causing error responses to be returned to the clients. For a short amount of time, new requests may be routed to that process. These requests will receive error responses. In Passenger 5 we've introduced a new, graceful mechanism for terminating application processes: passenger-config detach-process. This command removes the process from the load balancing list, drains all existing requests, then terminates it cleanly.

You can learn more about this tool by running:

passenger-config detach-process --help

来源:https://blog.phusion.nl/2015/03/04/whats-new-in-passenger-5-part-2-better-logging-better-restarting-better-websockets-and-more/