Exemplo n.º 1
0
static void
hup_handler(int sig)
{
	route *newroutes;
	cluster *newclusters;
	int id;
	FILE *newfd;

	logout("caught SIGHUP...\n");
	if (relay_stderr != stderr) {
		/* try to re-open the file first, so we can still try and say
		 * something if that fails */
		if ((newfd = fopen(relay_logfile, "a")) == NULL) {
			logerr("not reopening logfiles: can't open '%s': %s\n",
					relay_logfile, strerror(errno));
		} else {
			logout("closing logfile\n");
			relay_can_log = 0;
			fclose(relay_stderr);
			relay_stdout = newfd;
			relay_stderr = newfd;
			relay_can_log = 1;
			logout("reopening logfile\n");
		}
	}
	logout("reloading config from '%s'...\n", config);

	if (router_readconfig(&newclusters, &newroutes,
				config, queuesize, batchsize) == 0)
	{
		logerr("failed to read configuration '%s', aborting reload\n",
				config);
		return;
	}
	router_optimise(&newroutes);

	logout("reloading worker");
	for (id = 1; id < 1 + workercnt; id++)
		dispatch_schedulereload(workers[id + 0], newroutes);
	for (id = 1; id < 1 + workercnt; id++) {
		while (!dispatch_reloadcomplete(workers[id + 0]))
			usleep((100 + (rand() % 200)) * 1000);  /* 100ms - 300ms */
		fprintf(relay_stdout, " %d", id + 1);
		fflush(relay_stdout);
	}
	fprintf(relay_stdout, "\n");

	logout("reloading collector\n");
	collector_schedulereload(newclusters);
	while (!collector_reloadcomplete())
		usleep((100 + (rand() % 200)) * 1000);  /* 100ms - 300ms */

	router_free(clusters, routes);

	routes = newroutes;
	clusters = newclusters;

	logout("SIGHUP handler complete\n");
}
Exemplo n.º 2
0
/**
 * Initialises and starts the collector.
 */
void
collector_start(dispatcher **d, cluster *c, server *submission)
{
	dispatchers = d;
	collector_schedulereload(c);

	if (mode == DEBUG || mode == DEBUGTEST)
		debug = 1;

	if (mode != SUBMISSION) {
		if (pthread_create(&collectorid, NULL, collector_runner, submission) != 0)
			logerr("failed to start collector!\n");
	} else {
		if (pthread_create(&collectorid, NULL, collector_writer, NULL) != 0)
			logerr("failed to start collector!\n");
	}
}
Exemplo n.º 3
0
/**
 * Initialises and starts the collector.
 */
void
collector_start(dispatcher **d, router *rtr, server *submission, char cum)
{
	dispatchers = d;
	collector_schedulereload(rtr);

	if (mode & MODE_DEBUG)
		debug = 1;
	debug |= (cum ? 0 : 2);

	if (mode & MODE_SUBMISSION) {
		if (pthread_create(&collectorid, NULL, collector_writer, NULL) != 0)
			logerr("failed to start collector!\n");
	} else {
		if (pthread_create(&collectorid, NULL, collector_runner, submission) != 0)
			logerr("failed to start collector!\n");
	}
}
Exemplo n.º 4
0
/**
 * Initialises and starts the collector.
 */
void
collector_start(dispatcher **d, cluster *c, aggregator *a, server *submission, char cum)
{
	dispatchers = d;
	collector_schedulereload(c, a);

	if (mode == DEBUG || mode == DEBUGTEST || mode == DEBUGSUBMISSION)
		debug = 1;
	debug |= (cum ? 0 : 2);

	if (mode != SUBMISSION && mode != DEBUGSUBMISSION) {
		if (pthread_create(&collectorid, NULL, collector_runner, submission) != 0)
			logerr("failed to start collector!\n");
	} else {
		if (pthread_create(&collectorid, NULL, collector_writer, NULL) != 0)
			logerr("failed to start collector!\n");
	}
}