public static void main(String[] args) throws Exception {
        ArgumentParser parser = ArgumentParsers
            .newArgumentParser("trogdor-agent")
            .description("The Trogdor fault injection agent");
        parser.addArgument("--agent.config", "-c")
            .action(store())
            .required(true)
            .type(String.class)
            .dest("config")
            .metavar("CONFIG")
            .help("The configuration file to use.");
        parser.addArgument("--node-name", "-n")
            .action(store())
            .required(true)
            .type(String.class)
            .dest("node_name")
            .metavar("NODE_NAME")
            .help("The name of this node.");
        parser.addArgument("--exec", "-e")
            .action(store())
            .type(String.class)
            .dest("task_spec")
            .metavar("TASK_SPEC")
            .help("Execute a single task spec and then exit.  The argument is the task spec to load when starting up, or a path to it.");
        Namespace res = null;
        try {
            res = parser.parseArgs(args);
        } catch (ArgumentParserException e) {
            if (args.length == 0) {
                parser.printHelp();
                Exit.exit(0);
            } else {
                parser.handleError(e);
                Exit.exit(1);
            }
        }
        String configPath = res.getString("config");
        String nodeName = res.getString("node_name");
        String taskSpec = res.getString("task_spec");

        Platform platform = Platform.Config.parse(nodeName, configPath);
        JsonRestServer restServer =
            new JsonRestServer(Node.Util.getTrogdorAgentPort(platform.curNode()));
        AgentRestResource resource = new AgentRestResource();
        log.info("Starting agent process.");
        final Agent agent = new Agent(platform, Scheduler.SYSTEM, restServer, resource);
        restServer.start(resource);
        Exit.addShutdownHook("agent-shutdown-hook", () -> {
            log.warn("Running agent shutdown hook.");
            try {
                agent.beginShutdown();
                agent.waitForShutdown();
            } catch (Exception e) {
                log.error("Got exception while running agent shutdown hook.", e);
            }
        });
        if (taskSpec != null) {
            TaskSpec spec = null;
            try {
                spec = JsonUtil.objectFromCommandLineArgument(taskSpec, TaskSpec.class);
            } catch (Exception e) {
                System.out.println("Unable to parse the supplied task spec.");
                e.printStackTrace();
                Exit.exit(1);
            }
            TaskSpec effectiveSpec = agent.rebaseTaskSpecTime(spec);
            Exit.exit(agent.exec(effectiveSpec, System.out) ? 0 : 1);
        }
        agent.waitForShutdown();
    }
Start a task on the agent, and block until it completes.

@param spec          The task specifiction.
@param out           The output stream to print to.

@return              True if the task run successfully; false otherwise.
trogdor/src/main/java/org/apache/kafka/trogdor/agent/Agent.java