passenger passenger_log_file 日志分析

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,具体可以查看官方文档 。注意此处为达到最大的队列大小的原因是什么如果确实是请求并发高,可以加大该队列大小,但是如果为慢查询连接未被释放,则需要自己查看原因,而不是盲目加大该参数。


转载于:https://my.oschina.net/monkeyzhu/blog/595321

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值