+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include <sys/time.h>
+#include <sys/resource.h>
#include "common.h"
#include "log.h"
#include "daemon.h"
#include "web_server.h"
#include "popen.h"
-#include "config.h"
+#include "appconfig.h"
#include "web_client.h"
#include "rrd.h"
#include "rrd2json.h"
int config_loaded = 0;
int dont_fork = 0;
+ // global initialization
+ get_HZ();
+
// set the name for logging
program_name = "netdata";
fprintf(stderr, " -u USERNAME can be any system username to run as. Default: none.\n");
fprintf(stderr, " -ch path to access host /proc and /sys when running in a container. Default: empty.\n");
fprintf(stderr, " -nd or -nodeamon to disable forking in the background. Default: unset.\n");
- fprintf(stderr, " -df FLAGS debug options. Default: 0x%8llx.\n", debug_flags);
+ fprintf(stderr, " -df FLAGS debug options. Default: 0x%08llx.\n", debug_flags);
exit(1);
}
}
debug_flags = strtoull(flags, NULL, 0);
debug(D_OPTIONS, "Debug flags set to '0x%8llx'.", debug_flags);
+ if(debug_flags != 0) {
+ struct rlimit rl = { RLIM_INFINITY, RLIM_INFINITY };
+ if(setrlimit(RLIMIT_CORE, &rl) != 0)
+ info("Cannot request unlimited core dumps for debugging... Proceeding anyway...");
+ }
+
// --------------------------------------------------------------------
global_host_prefix = config_get("global", "host access prefix", "");
// --------------------------------------------------------------------
prepare_rundir();
- char *user = config_get("global", "run as user", (getuid() == 0)?"nobody":"");
+ char *user = config_get("global", "run as user", (getuid() == 0)?NETDATA_USER:"");
if(*user) {
if(become_user(user) != 0) {
fprintf(stderr, "Cannot become user %s.\n", user);
// never become a problem
if(nice(20) == -1) fprintf(stderr, "Cannot lower my CPU priority. Error: %s.\n", strerror(errno));
-#ifndef NETDATA_NO_DAEMON
+#ifdef NETDATA_DAEMON
if(become_daemon(dont_fork, 0, input_log_file, output_log_file, error_log_file, access_log_file, &access_fd, &stdaccess) == -1) {
fprintf(stderr, "Cannot demonize myself (%s).", strerror(errno));
exit(1);