Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Take 2] Add a PASSENGER_MAX_LOG_LINE_BYTES option increase the number of characters allowed per log line #2458

Merged
merged 5 commits into from
Jan 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Release 6.0.17 (Not yet released)
* Upgrades preferred Nginx to 1.22.1 from 1.20.2.
* Changes minimum supported macOS version to 10.14 Mojave.
* Adds support for arm (aarch64) rpm packages.
* Adds support for a `PASSENGER_MAX_LOG_LINE_LENGTH_BYTES` environment variable. The default length remains at 8KB. Closes GH-2413.
* Updated various library versions used in precompiled binaries (used for e.g. gem installs):
- ccache: 4.6.3 → 4.7.4
- curl: 7.86.0 → 7.87.0
Expand Down
21 changes: 18 additions & 3 deletions src/agent/Core/SpawningKit/PipeWatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class PipeWatcher: public boost::enable_shared_from_this<PipeWatcher> {
string logFile;
boost::mutex startSyncher;
boost::condition_variable startCond;
size_t bufSize;
char *buf;

static void threadMain(boost::shared_ptr<PipeWatcher> self) {
TRACE_POINT();
Expand Down Expand Up @@ -90,11 +92,12 @@ class PipeWatcher: public boost::enable_shared_from_this<PipeWatcher> {

UPDATE_TRACE_POINT();
while (!boost::this_thread::interruption_requested()) {
char buf[1024 * 8];
ssize_t ret;

buf[0] = '\0';

UPDATE_TRACE_POINT();
ret = syscalls::read(fd, buf, sizeof(buf));
ret = syscalls::read(fd, buf, bufSize);
if (ret == 0) {
break;
} else if (ret == -1) {
Expand Down Expand Up @@ -150,14 +153,26 @@ class PipeWatcher: public boost::enable_shared_from_this<PipeWatcher> {
appGroupName(_appGroupName),
appLogFile(_appLogFile),
pid(_pid),
started(false)
started(false),
bufSize(1024 * 8),
buf(NULL)
{ }

~PipeWatcher() {
delete[] buf;
}

void setLogFile(const string &path) {
logFile = path;
}

void initialize() {
const char *envMaxLogBytes = getenv("PASSENGER_MAX_LOG_LINE_LENGTH_BYTES");
if (envMaxLogBytes != NULL && *envMaxLogBytes != '\0') {
bufSize = atoi(envMaxLogBytes);
}
buf = new char[bufSize];

oxt::thread(boost::bind(threadMain, shared_from_this()),
"PipeWatcher: PID " + toString(pid) + " " + name + ", fd " + toString(fd),
POOL_HELPER_THREAD_STACK_SIZE);
Expand Down