您的位置:首页 > 其它

passenger passenger_log_file 日志分析

2015-12-31 16:26 302 查看

passenger passenger_log_file 日志分析

通过日志来分析相关逻辑及调优,主要使用正则表达式来找出具体源文件位置。

App pid stdout 正则表达式
App.+?stdout

日志输出:
App 7375 stdout:
App 7383 stdout:
App 7391 stdout:
App 7401 stdout:

在Spawner.h中
string readMessageLine(Details &details) {
TRACE_POINT();
while (true) {
string result = details.io.readLine(1024 * 4, &details.timeout);
string line = result;
if (!line.empty() && line[line.size() - 1] == '\n') {
line.erase(line.size() - 1, 1);
}

if (result.empty()) {
// EOF
return result;
} else if (startsWith(result, "!> ")) {
P_DEBUG("[App " << details.pid << " stdout] " << line);
result.erase(0, sizeof("!> ") - 1);
return result;
} else {
if (details.stderrCapturer != NULL) {
details.stderrCapturer->appendToBuffer(result);
}
printAppOutput(details.pid, "stdout", line.data(), line.size());
}
}
}

通过文件名和代码内容能看出为spawn进程时所产生日志。

Disconnecting long-running connections for process 20545
正则表达式Disconnecting long-running connections for process

static void
abortLongRunningConnections(const ApplicationPool2::ProcessPtr &process) {
// We are inside the ApplicationPool lock. Be very careful here.
WorkingObjects *wo = workingObjects;
P_NOTICE("Disconnecting long-running connections for process " <<
process->getPid() << ", application " << process->getGroup()->getName());
for (unsigned int i = 0; i < wo->threadWorkingObjects.size(); i++) {
wo->threadWorkingObjects[i].bgloop->safe->runLater(
boost::bind(abortLongRunningConnectionsOnController,
wo->threadWorkingObjects[i].controller,
process->getGupid().toString()));
}
}

通过函数名和逻辑可判断为进程在达到最大空闲时间后,被kill进程时输出的日志。

Returning HTTP 503 due to: Request queue full (configured max. size: 100)
Returning HTTP

在CheckoutSession.cpp文件中
void
Controller::writeRequestQueueFullExceptionErrorResponse(Client *client, Request *req,
const boost::shared_ptr<RequestQueueFullException> &e)
{
TRACE_POINT();
const LString *value = req->secureHeaders.lookup(
"!~PASSENGER_REQUEST_QUEUE_OVERFLOW_STATUS_CODE");
int requestQueueOverflowStatusCode = 503;
if (value != NULL && value->size > 0) {
value = psg_lstr_make_contiguous(value, req->pool);
requestQueueOverflowStatusCode = stringToInt(
StaticString(value->start->data, value->size));
}

SKC_WARN(client, "Returning HTTP " << requestQueueOverflowStatusCode <<
" due to: " << e->what());

endRequestWithSimpleResponse(&client, &req,
"<h2>This website is under heavy load (queue full)</h2>"
"<p>We're sorry, too many people are accessing this website at the same "
"time. We're working on this problem. Please try again later.</p>",
requestQueueOverflowStatusCode);
}

明显此处Request queue full,并且返回给用户This website is under heavy load的页面,默认为最大为100,具体可以查看官方文档 。注意此处为达到最大的队列大小的原因是什么如果确实是请求并发高,可以加大该队列大小,但是如果为慢查询连接未被释放,则需要自己查看原因,而不是盲目加大该参数。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: