| 555 | |
| 556 | |
| 557 | int main(int argc, char** argv) |
| 558 | { |
| 559 | Flags flags; |
| 560 | Try<flags::Warnings> load = flags.load("MESOS_EXAMPLE_", argc, argv); |
| 561 | |
| 562 | if (flags.help) { |
| 563 | std::cout << flags.usage() << std::endl; |
| 564 | return EXIT_SUCCESS; |
| 565 | } |
| 566 | |
| 567 | if (load.isError()) { |
| 568 | std::cerr << flags.usage(load.error()) << std::endl; |
| 569 | return EXIT_FAILURE; |
| 570 | } |
| 571 | |
| 572 | mesos::internal::logging::initialize(argv[0], false); |
| 573 | |
| 574 | // Log any flag warnings. |
| 575 | foreach (const flags::Warning& warning, load->warnings) { |
| 576 | LOG(WARNING) << warning.message; |
| 577 | } |
| 578 | |
| 579 | const Resources resources = Resources::parse( |
| 580 | "cpus:" + stringify(CPUS_PER_EXECUTOR) + |
| 581 | ";mem:" + stringify(MEM_PER_EXECUTOR)).get(); |
| 582 | |
| 583 | ExecutorInfo executor; |
| 584 | executor.mutable_executor_id()->set_value("default"); |
| 585 | executor.mutable_resources()->CopyFrom(resources); |
| 586 | executor.set_name(EXECUTOR_NAME); |
| 587 | |
| 588 | // Determine the command to run the executor based on three possibilities: |
| 589 | // 1) `--executor_command` was set, which overrides the below cases. |
| 590 | // 2) We are in the Mesos build directory, so the targeted executable |
| 591 | // is actually a libtool wrapper script. |
| 592 | // 3) We have not detected the Mesos build directory, so assume the |
| 593 | // executor is in the same directory as the framework. |
| 594 | string command; |
| 595 | |
| 596 | // Find this executable's directory to locate executor. |
| 597 | if (flags.executor_command.isSome()) { |
| 598 | command = flags.executor_command.get(); |
| 599 | } else if (flags.build_dir.isSome()) { |
| 600 | command = path::join(flags.build_dir.get(), "src", EXECUTOR_BINARY); |
| 601 | } else { |
| 602 | command = |
| 603 | path::join(os::realpath(Path(argv[0]).dirname()).get(), EXECUTOR_BINARY); |
| 604 | } |
| 605 | |
| 606 | executor.mutable_command()->set_value(command); |
| 607 | |
| 608 | if (flags.executor_uris.isSome() && flags.executor_uri.isSome()) { |
| 609 | EXIT(EXIT_FAILURE) |
| 610 | << "Flag '--executor_uris' shall not be used with '--executor_uri'"; |
| 611 | } |
| 612 | |
| 613 | // Copy `--executor_uri` into the command. |
| 614 | if (flags.executor_uri.isSome()) { |
nothing calls this directly
no test coverage detected