/*
* innduct
* tailing reliable realtime streaming feeder for inn
- * innduct.c - main program, option parsing and startup
+ * duct.c - main program, option parsing and startup
*
* Copyright (C) 2010 Ian Jackson <ijackson@chiark.greenend.org.uk>
*
int *lowvol_perperiod;
int lowvol_circptr;
int lowvol_total; /* does not include current period */
+int until_stats_log=1;
/*---------- configuration option variables ----------*/
/* when changing defaults, remember to update the manpage */
int spontaneous_flush_periods=100000;
int max_separated_periods=2000;
int need_activity_periods=1000;
+int stats_log_periods=2500;
int lowvol_thresh=3;
int lowvol_periods=1000;
free(dipf_flushing);
free(dipf_backlog);
+ if (until_stats_log) until_stats_log--;
+ else showstats();
+
if (until_connect) until_connect--;
inputfile_queue_check_expired(backlog_input_file);
static void vbadusage(const char *fmt, va_list al) NORET_PRINTF(1,0);
static void vbadusage(const char *fmt, va_list al) {
- char *m= xvasprintf(fmt,al);
+ char *m= mvasprintf(fmt,al);
fprintf(stderr, "bad usage: %s\n"
"say --help for help, or read the manpage\n",
m);
const Option *o;
for (o=options; o->shrt || o->lng; o++) {
char shrt[2] = { o->shrt, 0 };
- char *optspec= xasprintf("%s%s%s%s%s",
+ char *optspec= masprintf("%s%s%s%s%s",
o->shrt ? "-" : "", shrt,
o->shrt && o->lng ? "|" : "",
DELIMPERHAPS("--", o->lng));
{0,"max-flush-interval", "PERIOD", &spontaneous_flush_periods,op_seconds },
{0,"flush-finish-timeout", "PERIOD", &max_separated_periods, op_seconds },
{0,"idle-timeout", "PERIOD", &need_activity_periods, op_seconds },
+{0,"stats-log-interval", "PERIOD", &stats_log_periods, op_seconds },
{0,"low-volume-thresh", "PERIOD", &lowvol_thresh, op_integer },
{0,"low-volume-window", "PERIOD", &lowvol_periods, op_seconds },
print_options(innduct_options, f);
}
+static void printcopyright(FILE *f) {
+ fputs(
+ "innduct is Copyright (C)2010 Ian Jackson.\n"
+ "It is free software, licenced under GPL version 3 or later.\n"
+ "It is provided WITHOUT ANY WARRANTY. See the file GPL-3 for details\n",
+ stderr);
+}
+
static void help(const Option *o, const char *val) {
printusage(stdout);
if (ferror(stdout) || fflush(stdout)) {
if (!argv[1]) {
printusage(stderr);
+ printcopyright(stderr);
exit(8);
}
convert_to_periods_rndup(&spontaneous_flush_periods);
convert_to_periods_rndup(&max_separated_periods);
convert_to_periods_rndup(&need_activity_periods);
+ convert_to_periods_rndup(&stats_log_periods);
convert_to_periods_rndup(&lowvol_periods);
if (max_bad_data_ratio < 0 || max_bad_data_ratio > 100)
if (!feedfile) feedfile= sitename;
if (!feedfile[0]) badusage("feed filename, if specified, must be nonempty");
if (path_ends_slash(feedfile))
- feedfile= xasprintf("%s%s", feedfile, sitename);
+ feedfile= masprintf("%s%s", feedfile, sitename);
if (feedfile[0] != '/')
- feedfile= xasprintf("%s/%s", innconf->pathoutgoing, feedfile);
+ feedfile= masprintf("%s/%s", innconf->pathoutgoing, feedfile);
if (!path_cli) {
path_cli_dir= "innduct";
} else if (!path_cli[0] || !strcmp(path_cli,"none")) {
path_cli= 0; /* ok, don't then */
} else if (path_ends_slash(path_cli)) {
- path_cli_dir= xasprintf("%.*s", strlen(path_cli)-1, path_cli);
+ path_cli_dir= masprintf("%.*s", strlen(path_cli)-1, path_cli);
}
if (path_cli_dir)
- path_cli= xasprintf("%s/%s", path_cli_dir, sitename);
+ path_cli= masprintf("%s/%s", path_cli_dir, sitename);
if (max_queue_per_ipf<0)
max_queue_per_ipf= max_queue_per_conn * 2;
/* set things up */
- path_lock= xasprintf("%s_lock", feedfile);
- path_flushing= xasprintf("%s_flushing", feedfile);
- path_defer= xasprintf("%s_defer", feedfile);
- path_dump= xasprintf("%s_dump", feedfile);
- globpat_backlog= xasprintf("%s_backlog*", feedfile);
+ path_lock= masprintf("%s_lock", feedfile);
+ path_flushing= masprintf("%s_flushing", feedfile);
+ path_defer= masprintf("%s_defer", feedfile);
+ path_dump= masprintf("%s_dump", feedfile);
+ globpat_backlog= masprintf("%s_backlog*", feedfile);
oop_source_sys *sysloop= oop_sys_new();
if (!sysloop) syscrash("could not create liboop event loop");
close(i);
}
- logv_prefix= xasprintf("%s| ", sitename);
+ logv_prefix= masprintf("%s| ", sitename);
if (interactive < 2) {
openlog("innduct",LOG_NDELAY|LOG_PID,LOG_NEWS);
logv_use_syslog= 1;
dup2(null,2);
xclose(null, "/dev/null original fd",0);
- pid_t child1= xfork("daemonise first fork");
+ pid_t child1= xfork_bare("daemonise first fork");
if (child1) _exit(0);
pid_t sid= setsid();
if (sid == -1) sysdie("setsid failed");
- pid_t child2= xfork("daemonise second fork");
+ pid_t child2= xfork_bare("daemonise second fork");
if (child2) _exit(0);
}