Apache Mesos
systemd.hpp
Go to the documentation of this file.
1 // Licensed to the Apache Software Foundation (ASF) under one
2 // or more contributor license agreements. See the NOTICE file
3 // distributed with this work for additional information
4 // regarding copyright ownership. The ASF licenses this file
5 // to you under the Apache License, Version 2.0 (the
6 // "License"); you may not use this file except in compliance
7 // with the License. You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 
17 #ifndef __SYSTEMD_HPP__
18 #define __SYSTEMD_HPP__
19 
20 #include <process/subprocess.hpp>
21 
22 #include <stout/flags.hpp>
23 #include <stout/nothing.hpp>
24 #include <stout/path.hpp>
25 #include <stout/try.hpp>
26 
27 namespace systemd {
28 
29 // TODO(jmlvanre): Consider moving the generic systemd behaviour into
30 // stout, and leaving the mesos specific behavior here.
31 namespace mesos {
32 
40 // TODO(jmlvanre): We may want to allow this to be configured.
41 static const char MESOS_EXECUTORS_SLICE[] = "mesos_executors.slice";
42 
43 
52 
53 } // namespace mesos {
54 
55 
59 class Flags : public virtual flags::FlagsBase
60 {
61 public:
62  Flags();
63 
64  bool enabled;
65  std::string runtime_directory;
66  std::string cgroups_hierarchy;
67 };
68 
69 
70 const Flags& flags();
71 
72 
79 
80 
93 bool exists();
94 
95 
99 bool enabled();
100 
101 
106 
107 
111 Path hierarchy();
112 
113 
122 
123 namespace slices {
124 
128 bool exists(const Path& path);
129 
130 
139 Try<Nothing> create(const Path& path, const std::string& data);
140 
141 
145 Try<Nothing> start(const std::string& name);
146 
147 } // namespace slices {
148 
149 } // namespace systemd {
150 
151 #endif // __SYSTEMD_HPP__
bool enabled()
Check if systemd exists, and whether we have initialized it.
Definition: path.hpp:26
Try< Nothing > extendLifetime(pid_t child)
A hook that is executed in the parent process.
Try< Nothing > create(const Path &path, const std::string &data)
Creates a slice configuration with the provided contents at the given path.
Definition: check.hpp:33
std::string runtime_directory
Definition: systemd.hpp:65
Try< Nothing > start(const std::string &name)
Starts the slice with the given name (via &#39;systemctl start <name>&#39;).
Definition: systemd.hpp:27
Path runtimeDirectory()
Returns the path to the runtime directory for systemd units.
DWORD pid_t
Definition: windows.hpp:187
bool enabled
Definition: systemd.hpp:64
Try< Nothing > initialize(const Flags &flags)
Initialized state for support of systemd functions in this file.
Represents a POSIX or Windows file system path and offers common path manipulations.
Definition: path.hpp:145
Definition: flags.hpp:44
Definition: spec.hpp:30
Try< Nothing > daemonReload()
Runs systemctl daemon-reload.
std::string cgroups_hierarchy
Definition: systemd.hpp:66
Path hierarchy()
Return the path to the systemd hierarchy.
Flags to initialize systemd state.
Definition: systemd.hpp:59
bool exists()
Check if we are on a systemd environment by: (1) Testing whether /sbin/init links to systemd...
const Flags & flags()
Definition: parse.hpp:33
constexpr const char * name
Definition: shell.hpp:43