X-Git-Url: https://arthur.barton.de/gitweb/?a=blobdiff_plain;f=src%2Fmain.c;h=a72585e28377a1157bcae85459bc73176b14d8d3;hb=8a870a65d0afc49455b4b5ff2b0ce585e0bd8339;hp=f2487f41952ee92166688792515d1c64936b8b35;hpb=40692f13038ef3e15defb7cf2bc1ad7b876e4ed5;p=netdata.git diff --git a/src/main.c b/src/main.c index f2487f41..a72585e2 100644 --- a/src/main.c +++ b/src/main.c @@ -230,6 +230,7 @@ struct option_def options[] = { { 't', "The internal clock of netdata.", "seconds", "1"}, { 'u', "Run as user.", "username", "netdata"}, { 'v', "Print netdata version and exit.", NULL, NULL}, + { 'V', "Print netdata version and exit.", NULL, NULL}, { 'W', "See Advanced options below.", "options", NULL}, }; @@ -365,7 +366,10 @@ static void backwards_compatible_config() { web_server_mode = (mode)?WEB_SERVER_MODE_MULTI_THREADED:WEB_SERVER_MODE_SINGLE_THREADED; } - // move [global] options to the [api] section + // move [global] options to the [web] section + config_move(CONFIG_SECTION_GLOBAL, "http port listen backlog", + CONFIG_SECTION_WEB, "listen backlog"); + config_move(CONFIG_SECTION_GLOBAL, "bind socket to IP", CONFIG_SECTION_WEB, "bind to"); @@ -411,7 +415,7 @@ static void get_netdata_configured_variables() { char buf[HOSTNAME_MAX + 1]; if(gethostname(buf, HOSTNAME_MAX) == -1) - error("WARNING: Cannot get machine hostname."); + error("Cannot get machine hostname."); netdata_configured_hostname = config_get(CONFIG_SECTION_GLOBAL, "hostname", buf); debug(D_OPTIONS, "hostname set to '%s'", netdata_configured_hostname); @@ -513,6 +517,9 @@ void set_global_environment() { // disable buffering for python plugins setenv("PYTHONUNBUFFERED", "1", 1); + + // switch to standard locale for plugins + setenv("LC_ALL", "C", 1); } int main(int argc, char **argv) { @@ -611,6 +618,7 @@ int main(int argc, char **argv) { config_set(CONFIG_SECTION_GLOBAL, "run as user", optarg); break; case 'v': + case 'V': printf("%s %s\n", program_name, program_version); return 0; case 'W': @@ -851,7 +859,13 @@ int main(int argc, char **argv) { // get the user we should run // IMPORTANT: this is required before web_files_uid() - user = config_get(CONFIG_SECTION_GLOBAL, "run as user" , (getuid() == 0)?NETDATA_USER:""); + if(getuid() == 0) { + user = config_get(CONFIG_SECTION_GLOBAL, "run as user", NETDATA_USER); + } + else { + struct passwd *passwd = getpwuid(getuid()); + user = config_get(CONFIG_SECTION_GLOBAL, "run as user", (passwd && passwd->pw_name)?passwd->pw_name:""); + } // IMPORTANT: these have to run once, while single threaded web_files_uid(); // IMPORTANT: web_files_uid() before web_files_gid()