You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2016/04/25 23:36:08 UTC
[27/48] 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/56a1edf0
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/56a1edf0
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/56a1edf0
Branch: refs/heads/0.27.x
Commit: 56a1edf05e0f1b450e9e2461bb15246ef4a0ae66
Parents: 60dc7ab
Author: Joris Van Remoortere <jo...@gmail.com>
Authored: Fri Feb 5 14:52:18 2016 -0500
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Tue Feb 16 18:21:10 2016 -0500
----------------------------------------------------------------------
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/56a1edf0/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());