diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-04-14 18:12:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-04-14 18:12:10 +0000 |
commit | b5321aff06d6ea8d730d62aec2ffd8e9271c1ffc (patch) | |
tree | 36c41e35994786456154f9d3bf88c324763aeea4 /daemon/main.c | |
parent | Adding upstream version 1.33.1. (diff) | |
download | netdata-b5321aff06d6ea8d730d62aec2ffd8e9271c1ffc.tar.xz netdata-b5321aff06d6ea8d730d62aec2ffd8e9271c1ffc.zip |
Adding upstream version 1.34.0.upstream/1.34.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'daemon/main.c')
-rw-r--r-- | daemon/main.c | 53 |
1 files changed, 24 insertions, 29 deletions
diff --git a/daemon/main.c b/daemon/main.c index 7c8e09a5..c1877897 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -250,6 +250,8 @@ void cancel_main_threads() { else info("All threads finished."); + for (i = 0; static_threads[i].name != NULL ; i++) + freez(static_threads[i].thread); free(static_threads); } @@ -445,15 +447,6 @@ static void backwards_compatible_config() { config_move(CONFIG_SECTION_GLOBAL, "web compression level", CONFIG_SECTION_WEB, "gzip compression level"); - - config_move(CONFIG_SECTION_GLOBAL, "web files owner", - CONFIG_SECTION_WEB, "web files owner"); - - config_move(CONFIG_SECTION_GLOBAL, "web files group", - CONFIG_SECTION_WEB, "web files group"); - - config_move(CONFIG_SECTION_BACKEND, "opentsdb host tags", - CONFIG_SECTION_BACKEND, "host tags"); } static void get_netdata_configured_variables() { @@ -690,6 +683,7 @@ int main(int argc, char **argv) { int i; int config_loaded = 0; int dont_fork = 0; + bool close_open_fds = true; size_t default_stacksize; char *user = NULL; @@ -794,8 +788,13 @@ int main(int argc, char **argv) { } if(strcmp(optarg, "unittest") == 0) { - if(unit_test_buffer()) return 1; - if(unit_test_str2ld()) return 1; + if (unit_test_static_threads()) + return 1; + if (unit_test_buffer()) + return 1; + if (unit_test_str2ld()) + return 1; + // No call to load the config file on this code-path post_conf_load(&user); get_netdata_configured_variables(); @@ -1038,7 +1037,13 @@ int main(int argc, char **argv) { print_build_info_json(); return 0; } - else { + else if(strcmp(optarg, "keepopenfds") == 0) { + // Internal dev option to skip closing inherited + // open FDs. Useful, when we want to run the agent + // under profiling tools that open/maintain their + // own FDs. + close_open_fds = false; + } else { fprintf(stderr, "Unknown -W parameter '%s'\n", optarg); return help(1); } @@ -1053,12 +1058,12 @@ int main(int argc, char **argv) { } #ifdef _SC_OPEN_MAX - // close all open file descriptors, except the standard ones - // the caller may have left open files (lxc-attach has this issue) - { - int fd; - for(fd = (int) (sysconf(_SC_OPEN_MAX) - 1); fd > 2; fd--) - if(fd_is_valid(fd)) close(fd); + if (close_open_fds == true) { + // close all open file descriptors, except the standard ones + // the caller may have left open files (lxc-attach has this issue) + for(int fd = (int) (sysconf(_SC_OPEN_MAX) - 1); fd > 2; fd--) + if(fd_is_valid(fd)) + close(fd); } #endif @@ -1205,11 +1210,6 @@ int main(int argc, char **argv) { info("netdata started on pid %d.", getpid()); - // IMPORTANT: these have to run once, while single threaded - // but after we have switched user - web_files_uid(); - web_files_gid(); - netdata_threads_init_after_fork((size_t)config_get_number(CONFIG_SECTION_GLOBAL, "pthread stack size", (long)default_stacksize)); // initialize internal registry @@ -1232,6 +1232,7 @@ int main(int argc, char **argv) { struct rrdhost_system_info *system_info = calloc(1, sizeof(struct rrdhost_system_info)); get_system_info(system_info); system_info->hops = 0; + get_install_type(&system_info->install_type, &system_info->prebuilt_arch, &system_info->prebuilt_dist); if(rrd_init(netdata_configured_hostname, system_info)) fatal("Cannot initialize localhost instance with name '%s'.", netdata_configured_hostname); @@ -1317,12 +1318,6 @@ int main(int argc, char **argv) { snprintfz(filename, FILENAME_MAX, "%s/.aclk_report_sent", netdata_configured_varlib_dir); if (netdata_anonymous_statistics_enabled > 0 && access(filename, F_OK)) { // -1 -> not initialized send_statistics("ACLK_DISABLED", "-", "-"); -#ifdef ACLK_NO_LWS - send_statistics("BUILD_FAIL_LWS", "-", "-"); -#endif -#ifdef ACLK_NO_LIBMOSQ - send_statistics("BUILD_FAIL_MOSQ", "-", "-"); -#endif int fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 444); if (fd == -1) error("Cannot create file '%s'. Please fix this.", filename); |