You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jo...@apache.org on 2016/02/10 18:12:18 UTC
[7/8] mesos git commit: Extended life of logrotate processes on
systemd.
Extended life of logrotate processes on systemd.
Review: https://reviews.apache.org/r/43308
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/50d85172
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/50d85172
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/50d85172
Branch: refs/heads/master
Commit: 50d85172e68f25ebfa1e86611fb4a333b0ecc8f9
Parents: 435a147
Author: Joris Van Remoortere <jo...@gmail.com>
Authored: Fri Feb 5 14:52:18 2016 -0500
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Wed Feb 10 18:12:05 2016 +0100
----------------------------------------------------------------------
src/slave/container_loggers/lib_logrotate.cpp | 25 ++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/50d85172/src/slave/container_loggers/lib_logrotate.cpp
----------------------------------------------------------------------
diff --git a/src/slave/container_loggers/lib_logrotate.cpp b/src/slave/container_loggers/lib_logrotate.cpp
index 01a3ff0..cf5f238 100644
--- a/src/slave/container_loggers/lib_logrotate.cpp
+++ b/src/slave/container_loggers/lib_logrotate.cpp
@@ -41,6 +41,10 @@
#include <stout/os/fcntl.hpp>
#include <stout/os/killtree.hpp>
+#ifdef __linux__
+#include "linux/systemd.hpp"
+#endif // __linux__
+
#include "slave/container_loggers/logrotate.hpp"
#include "slave/container_loggers/lib_logrotate.hpp"
@@ -119,6 +123,17 @@ public:
outFlags.log_filename = path::join(sandboxDirectory, "stdout");
outFlags.logrotate_path = flags.logrotate_path;
+ // If we are on systemd, then extend the life of the process as we
+ // do with the executor. Any grandchildren's lives will also be
+ // extended.
+ std::vector<Subprocess::Hook> parentHooks;
+#ifdef __linux__
+ if (systemd::enabled()) {
+ parentHooks.emplace_back(Subprocess::Hook(
+ &systemd::mesos::extendLifetime));
+ }
+#endif // __linux__
+
Try<Subprocess> outProcess = subprocess(
path::join(flags.launcher_dir, mesos::internal::logger::rotate::NAME),
{mesos::internal::logger::rotate::NAME},
@@ -126,7 +141,10 @@ public:
Subprocess::PATH("/dev/null"),
Subprocess::FD(STDERR_FILENO),
outFlags,
- environment);
+ environment,
+ None(),
+ None(),
+ parentHooks);
if (outProcess.isError()) {
os::close(outfds.write.get());
@@ -170,7 +188,10 @@ public:
Subprocess::PATH("/dev/null"),
Subprocess::FD(STDERR_FILENO),
errFlags,
- environment);
+ environment,
+ None(),
+ None(),
+ parentHooks);
if (errProcess.isError()) {
os::close(outfds.write.get());