Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Merge pull request #902 from EOSIO/launcher-configurable-graylog-268
Browse files Browse the repository at this point in the history
 Make GELF logging optional and endpoint customizable in launcher.
  • Loading branch information
heifner authored Dec 9, 2017
2 parents a24ebc6 + 3c219c6 commit b775b04
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
2 changes: 1 addition & 1 deletion libraries/appbase
Submodule appbase updated 1 files
+9 −9 application.cpp
4 changes: 2 additions & 2 deletions programs/eosd/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ void initialize_logging()
int main(int argc, char** argv)
{
try {
initialize_logging();
app().set_version(eosio::eosd::config::version);
ilog("eosd version ${ver}", ("ver", eosio::eosd::config::itoh(static_cast<uint32_t>(app().version()))));
app().register_plugin<net_api_plugin>();
app().register_plugin<chain_api_plugin>();
app().register_plugin<wallet_api_plugin>();
Expand All @@ -55,6 +53,8 @@ int main(int argc, char** argv)
app().register_plugin<txn_test_gen_plugin>();
if(!app().initialize<chain_plugin, http_plugin, net_plugin>(argc, argv))
return -1;
initialize_logging();
ilog("eosd version ${ver}", ("ver", eosio::eosd::config::itoh(static_cast<uint32_t>(app().version()))));
app().startup();
app().exec();
} catch (const fc::exception& e) {
Expand Down
36 changes: 21 additions & 15 deletions programs/launcher/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ class tn_node_def {
vector<string> peers;
vector<string> producers;
eosd_def* instance;
string gelf_endpoint;
};

void
Expand Down Expand Up @@ -268,6 +269,7 @@ struct remote_deploy {
};

struct testnet_def {
string name;
remote_deploy ssh_helper;
map <string,tn_node_def> nodes;
};
Expand Down Expand Up @@ -333,12 +335,13 @@ struct launcher_def {
bool skip_transaction_signatures = false;
string eosd_extra_args;
testnet_def network;
string alias_base;
string gelf_endpoint;
vector <string> aliases;
vector <host_def> bindings;
int per_host = 0;
last_run_def last_run;
int start_delay = 0;
bool gelf_enabled;
bool nogen;
bool add_enable_stale_production = false;
string launch_name;
Expand Down Expand Up @@ -388,6 +391,9 @@ launcher_def::set_options (bpo::options_description &cli) {
("host-map",bpo::value<bf::path>(&host_map_file)->default_value(""),"a file containing mapping specific nodes to hosts. Used to enhance the custom shape argument")
("servers",bpo::value<bf::path>(&server_ident_file)->default_value(""),"a file containing ip addresses and names of individual servers to deploy as producers or observers ")
("per-host",bpo::value<int>(&per_host)->default_value(0),"specifies how many eosd instances will run on a single host. Use 0 to indicate all on one.")
("network-name",bpo::value<string>(&network.name)->default_value("testnet_"),"network name prefix used in GELF logging source")
("enable-gelf-logging",bpo::value<bool>(&gelf_enabled)->default_value(true),"enable gelf logging appender in logging configuration file")
("gelf-endpoint",bpo::value<string>(&gelf_endpoint)->default_value("10.160.11.21:12201"),"hostname:port or ip:port of GELF endpoint")
;
}

Expand Down Expand Up @@ -452,7 +458,6 @@ launcher_def::initialize (const variables_map &vmap) {

producers = 21;
data_dir_base = "tn_data_";
alias_base = "testnet_";
next_node = 0;

load_servers ();
Expand Down Expand Up @@ -518,7 +523,7 @@ void
launcher_def::assign_name (eosd_def &node) {
string dex = next_node < 10 ? "0":"";
dex += boost::lexical_cast<string,int>(next_node++);
node.name = alias_base + dex;
node.name = network.name + dex;
node.data_dir = data_dir_base + dex;
}

Expand Down Expand Up @@ -692,6 +697,7 @@ launcher_def::bind_nodes () {
ext += prod_nodes;
}
}
node.gelf_endpoint = gelf_endpoint;
network.nodes[node.name] = move(node);
inst.node = &network.nodes[inst.name];
i++;
Expand All @@ -718,7 +724,6 @@ launcher_def::find_host (const string &name)

host_def *
launcher_def::deploy_config_files (tn_node_def &node) {
bf::path filename;
boost::system::error_code ec;
eosd_def &instance = *node.instance;
host_def *host = find_host (instance.host);
Expand All @@ -727,7 +732,6 @@ launcher_def::deploy_config_files (tn_node_def &node) {
bf::path logging_source = stage / instance.data_dir / "logging.json";
if (host->is_local()) {
bf::path dd = bf::path(host->eos_root_dir) / instance.data_dir;
filename = dd / "config.ini";
if (bf::exists (dd)) {
int64_t count = bf::remove_all (dd / "blocks", ec);
if (ec.value() != 0) {
Expand All @@ -747,8 +751,8 @@ launcher_def::deploy_config_files (tn_node_def &node) {
<< " errno " << ec.value() << " " << strerror(ec.value()) << endl;
exit (-1);
}
bf::copy_file (logging_source, bf::path(host->eos_root_dir) / "logging.json", bf::copy_option::overwrite_if_exists);
bf::copy_file (source, filename, bf::copy_option::overwrite_if_exists);
bf::copy_file (logging_source, dd / "logging.json", bf::copy_option::overwrite_if_exists);
bf::copy_file (source, dd / "config.ini", bf::copy_option::overwrite_if_exists);
}
else {
prep_remote_config_dir (instance, host);
Expand All @@ -764,7 +768,7 @@ launcher_def::deploy_config_files (tn_node_def &node) {
exit(-1);
}

dpath = bf::path (host->eos_root_dir) / "logging.json";
dpath = bf::path (host->eos_root_dir) / instance.data_dir / "logging.json";

scp_cmd_line = compose_scp_command(*host, logging_source, dpath);

Expand Down Expand Up @@ -884,13 +888,15 @@ launcher_def::write_logging_config_file(tn_node_def &node) {
}

auto log_config = fc::logging_config::default_config();
log_config.appenders.push_back(
fc::appender_config( "net", "gelf",
fc::mutable_variant_object()
( "endpoint", "10.160.11.21:12201" )
( "host", instance.name )
) );
log_config.loggers.front().appenders.push_back("net");
if(gelf_enabled) {
log_config.appenders.push_back(
fc::appender_config( "net", "gelf",
fc::mutable_variant_object()
( "endpoint", node.gelf_endpoint )
( "host", instance.name )
) );
log_config.loggers.front().appenders.push_back("net");
}

auto str = fc::json::to_pretty_string( log_config, fc::json::stringify_large_ints_and_doubles );
cfg.write( str.c_str(), str.size() );
Expand Down

0 comments on commit b775b04

Please sign in to comment.