1983 {
1984
1985 variables_map vmap;
1986 options_description cfg ("Testnet launcher config options");
1987 options_description
cli (
"launcher command line options");
1989 string gts;
1991 string kill_arg;
1992 string bounce_nodes;
1993 string down_nodes;
1994 string roll_nodes;
1995 bfs::path config_dir;
1996 bfs::path config_file;
1997
2000
2002 ("timestamp,i",bpo::value<string>(>s),"set the timestamp for the first block. Use \"now\" to indicate the current time")
2003 ("launch,l",bpo::value<string>(), "select a subset of nodes to launch. Currently may be \"all\", \"none\", or \"local\". If not set, the default is to launch all unless an output file is named, in which case it starts none.")
2004 (
"output,o",bpo::value<bfs::path>(&top.
output),
"save a copy of the generated topology in this file")
2005 ("kill,k", bpo::value<string>(&kill_arg),"The launcher retrieves the previously started process ids and issues a kill to each.")
2006 ("down", bpo::value<string>(&down_nodes),"comma-separated list of node numbers that will be taken down using the sysio-tn_down.sh script")
2007 ("bounce", bpo::value<string>(&bounce_nodes),"comma-separated list of node numbers that will be restarted using the sysio-tn_bounce.sh script")
2008 ("roll", bpo::value<string>(&roll_nodes),"comma-separated list of host names where the nodes should be rolled to a new version using the sysio-tn_roll.sh script")
2009 ("version,v", "print version information")
2010 ("help,h","print this list")
2011 ("config-dir", bpo::value<bfs::path>(), "Directory containing configuration files such as config.ini")
2012 ("config,c", bpo::value<bfs::path>()->default_value( "config.ini" ), "Configuration file name relative to config-dir");
2013
2015
2016 try {
2017 bpo::store(bpo::parse_command_line(argc,
argv,
cli), vmap);
2018 bpo::notify(vmap);
2019
2021
2022 if (vmap.count("help") > 0) {
2024 return 0;
2025 }
2026 if (vmap.count("version") > 0) {
2027 cout << sysio::launcher::config::version_str << endl;
2028 return 0;
2029 }
2030
2031 if( vmap.count( "config-dir" ) ) {
2032 config_dir = vmap["config-dir"].as<bfs::path>();
2033 if( config_dir.is_relative() )
2034 config_dir = bfs::current_path() / config_dir;
2035 }
2036
2037 bfs::path config_file_name = config_dir / "config.ini";
2038 if( vmap.count( "config" ) ) {
2039 config_file_name = vmap["config"].as<bfs::path>();
2040 if( config_file_name.is_relative() )
2041 config_file_name = config_dir / config_file_name;
2042 }
2043
2044 if(!bfs::exists(config_file_name)) {
2045 if(config_file_name.compare(config_dir / "config.ini") != 0)
2046 {
2047 cout << "Config file " << config_file_name << " missing." << std::endl;
2048 return -1;
2049 }
2051 }
2052
2053
2054 bpo::store(bpo::parse_config_file<char>(config_file_name.make_preferred().string().c_str(),
2055 cfg, true), vmap);
2056
2057
2058
2059 if (vmap.count("launch")) {
2060 string l = vmap[
"launch"].as<
string>();
2061 if (boost::iequals(
l,
"all"))
2063 else if (boost::iequals(
l,
"local"))
2065 else if (boost::iequals(
l,
"remote"))
2067 else if (boost::iequals(
l,
"none"))
2069 else if (boost::iequals(
l,
"verify"))
2071 else {
2074 }
2075 }
2076 else {
2078 }
2079
2080 if (!kill_arg.empty()) {
2081 cout << "killing" << std::endl;
2082 if (kill_arg[0] != '-') {
2083 kill_arg = "-" + kill_arg;
2084 }
2085 top.
kill (mode, kill_arg);
2086 }
2087 else if (!bounce_nodes.empty()) {
2088 top.
bounce(bounce_nodes);
2089 }
2090 else if (!down_nodes.empty()) {
2091 top.
down(down_nodes);
2092 }
2093 else if (!roll_nodes.empty()) {
2094 top.
roll(roll_nodes);
2095 }
2096 else {
2100 }
2101 } catch (bpo::unknown_option &ex) {
2102 cerr << ex.what() << endl;
2104 }
2105 return 0;
2106}
struct local_identity local_id
void write_default_config(const bfs::path &cfg_file, const options_description &cfg)
void down(const string &node_numbers)
void set_options(bpo::options_description &cli)
void roll(const string &host_names)
void bounce(const string &node_numbers)
void start_all(string >s, launch_modes mode)
void kill(launch_modes mode, string sig_opt)
void initialize(const variables_map &vmap)