diff --git a/CHANGELOG b/CHANGELOG index ce13d81ba9..ee98c9aa81 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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 diff --git a/src/agent/Core/SpawningKit/PipeWatcher.h b/src/agent/Core/SpawningKit/PipeWatcher.h index 1e3830471f..e83a4b9173 100644 --- a/src/agent/Core/SpawningKit/PipeWatcher.h +++ b/src/agent/Core/SpawningKit/PipeWatcher.h @@ -63,6 +63,8 @@ class PipeWatcher: public boost::enable_shared_from_this { string logFile; boost::mutex startSyncher; boost::condition_variable startCond; + size_t bufSize; + char *buf; static void threadMain(boost::shared_ptr self) { TRACE_POINT(); @@ -90,11 +92,12 @@ class PipeWatcher: public boost::enable_shared_from_this { 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) { @@ -150,14 +153,26 @@ class PipeWatcher: public boost::enable_shared_from_this { 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);