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

Method commandCheck

src/checks/checker_process.cpp:463–545  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

461
462
463Future<int> CheckerProcess::commandCheck(
464 const check::Command& cmd,
465 const runtime::Plain& plain)
466{
467 const CommandInfo& command = cmd.info;
468
469 map<string, string> environment = os::environment();
470
471 foreach (const Environment::Variable& variable,
472 command.environment().variables()) {
473 environment[variable.name()] = variable.value();
474 }
475
476 // Launch the subprocess.
477 Try<Subprocess> s = Error("Not launched");
478
479 if (command.shell()) {
480 // Use the shell variant.
481 VLOG(1) << "Launching " << name << " '" << command.value() << "'"
482 << " for task '" << taskId << "'";
483
484 s = process::subprocess(
485 command.value(),
486 Subprocess::PATH(os::DEV_NULL),
487 Subprocess::FD(STDERR_FILENO),
488 Subprocess::FD(STDERR_FILENO),
489 environment,
490 getCustomCloneFunc(plain));
491 } else {
492 // Use the exec variant.
493 vector<string> argv(
494 std::begin(command.arguments()), std::end(command.arguments()));
495
496 VLOG(1) << "Launching " << name << " [" << command.value() << ", "
497 << strings::join(", ", argv) << "] for task '" << taskId << "'";
498
499 s = process::subprocess(
500 command.value(),
501 argv,
502 Subprocess::PATH(os::DEV_NULL),
503 Subprocess::FD(STDERR_FILENO),
504 Subprocess::FD(STDERR_FILENO),
505 nullptr,
506 environment,
507 getCustomCloneFunc(plain));
508 }
509
510 if (s.isError()) {
511 return Failure("Failed to create subprocess: " + s.error());
512 }
513
514 // TODO(alexr): Use lambda named captures for
515 // these cached values once it is available.
516 const pid_t commandPid = s->pid();
517 const string _name = name;
518 const Duration timeout = checkTimeout;
519 const TaskID _taskId = taskId;
520

Callers

nothing calls this directly

Calls 15

getCustomCloneFuncFunction · 0.85
FailureClass · 0.85
afterMethod · 0.80
errorMethod · 0.65
environmentFunction · 0.50
ErrorFunction · 0.50
subprocessFunction · 0.50
joinFunction · 0.50
killtreeFunction · 0.50
stringifyFunction · 0.50
valueMethod · 0.45
isErrorMethod · 0.45

Tested by

no test coverage detected