MCPcopy Create free account
hub / github.com/apache/mesos / main

Function main

src/launcher/docker_executor.cpp:80–266  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78
79
80int main(int argc, char** argv)
81{
82 GOOGLE_PROTOBUF_VERIFY_VERSION;
83
84#ifdef __WINDOWS__
85 // We need a handle to the job object which this container is associated with.
86 // Without this handle, the job object would be destroyed by the OS when the
87 // agent exits (or crashes), making recovery impossible. By holding a handle,
88 // we tie the lifetime of the job object to the container itself. In this way,
89 // a recovering agent can reattach to the container by opening a new handle to
90 // the job object.
91 const pid_t pid = ::GetCurrentProcessId();
92 const Try<std::wstring> name = os::name_job(pid);
93 if (name.isError()) {
94 cerr << "Failed to create job object name from pid: " << name.error()
95 << endl;
96 return EXIT_FAILURE;
97 }
98
99 // NOTE: This handle will not be destructed, even though it is a
100 // `SharedHandle`, because it will (purposefully) never go out of scope.
101 Try<SharedHandle> handle = os::open_job(JOB_OBJECT_QUERY, false, name.get());
102 if (handle.isError()) {
103 cerr << "Failed to open job object '" << stringify(name.get())
104 << "' for the current container: " << handle.error() << endl;
105 return EXIT_FAILURE;
106 }
107#endif // __WINDOWS__
108
109 mesos::internal::docker::Flags flags;
110
111 // Load flags from environment and command line.
112 Try<flags::Warnings> load = flags.load(None(), &argc, &argv);
113
114 if (flags.help) {
115 cout << flags.usage() << endl;
116 return EXIT_SUCCESS;
117 }
118
119 if (load.isError()) {
120 cerr << flags.usage(load.error()) << endl;
121 return EXIT_FAILURE;
122 }
123
124 mesos::internal::logging::initialize(argv[0], true, flags); // Catch signals.
125
126 // Log any flag warnings (after logging is initialized).
127 foreach (const flags::Warning& warning, load->warnings) {
128 LOG(WARNING) << warning.message;
129 }
130
131 VLOG(1) << stringify(flags);
132
133 if (flags.docker.isNone()) {
134 EXIT(EXIT_FAILURE) << flags.usage("Missing required option --docker");
135 }
136
137 if (flags.container.isNone()) {

Callers

nothing calls this directly

Calls 15

name_jobFunction · 0.85
open_jobFunction · 0.85
NoneClass · 0.85
finalizeFunction · 0.85
errorMethod · 0.65
runMethod · 0.65
stringifyFunction · 0.50
initializeFunction · 0.50
getenvFunction · 0.50
parseFunction · 0.50
createFunction · 0.50
isErrorMethod · 0.45

Tested by

no test coverage detected