| 63 | |
| 64 | |
| 65 | Try<Nothing> Replica::execute(int argc, char** argv) |
| 66 | { |
| 67 | flags.setUsageMessage( |
| 68 | "Usage: " + name() + " [options]\n" |
| 69 | "\n" |
| 70 | "This command is used to start a replica server.\n" |
| 71 | "\n"); |
| 72 | |
| 73 | // Configure the tool by parsing command line arguments. |
| 74 | if (argc > 0 && argv != nullptr) { |
| 75 | Try<flags::Warnings> load = flags.load(None(), argc, argv); |
| 76 | if (load.isError()) { |
| 77 | return Error(flags.usage(load.error())); |
| 78 | } |
| 79 | |
| 80 | if (flags.help) { |
| 81 | return Error(flags.usage()); |
| 82 | } |
| 83 | |
| 84 | process::initialize(); |
| 85 | logging::initialize(argv[0], false, flags); |
| 86 | |
| 87 | // Log any flag warnings (after logging is initialized). |
| 88 | foreach (const flags::Warning& warning, load->warnings) { |
| 89 | LOG(WARNING) << warning.message; |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | if (flags.quorum.isNone()) { |
| 94 | return Error(flags.usage("Missing required option --quorum")); |
| 95 | } |
| 96 | |
| 97 | if (flags.path.isNone()) { |
| 98 | return Error(flags.usage("Missing required option --path")); |
| 99 | } |
| 100 | |
| 101 | if (flags.servers.isNone()) { |
| 102 | return Error(flags.usage("Missing required option --servers")); |
| 103 | } |
| 104 | |
| 105 | if (flags.znode.isNone()) { |
| 106 | return Error(flags.usage("Missing required option --znode")); |
| 107 | } |
| 108 | |
| 109 | // Initialize the log. |
| 110 | if (flags.initialize) { |
| 111 | Initialize initialize; |
| 112 | initialize.flags.path = flags.path; |
| 113 | |
| 114 | Try<Nothing> execution = initialize.execute(); |
| 115 | if (execution.isError()) { |
| 116 | return Error(execution.error()); |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | // Create the log. |
| 121 | Log log( |
| 122 | flags.quorum.get(), |
nothing calls this directly
no test coverage detected