Exemplo n.º 1
0
static int do_site(void)
{
	int fd;
	int rv = -1;

	if (!cl.debug) {
		if (daemon(0, 0) < 0) {
			perror("daemon error");
			exit(EXIT_FAILURE);
		}
	}

	setup_logging();
	fd = lockfile();
	if (fd < 0)
		return fd;

	log_info("BOOTH cluster site daemon started");
	set_scheduler();
	set_oom_adj(-16);

	rv = loop(SITE);
	if (rv < 0)
		goto fail;

	unlink_lockfile(fd);
	close_logging();

	return 0;

fail:
	return -1;
}
Exemplo n.º 2
0
static void server_exit(void)
{
	int rv;

	if (lock_fd >= 0) {
		/* We might not be able to delete it, but at least
		 * make it empty. */
		rv = ftruncate(lock_fd, 0);
		(void)rv;
		unlink_lockfile(lock_fd);
	}
	log_info("exiting");
}
Exemplo n.º 3
0
Arquivo: main.c Projeto: aspiers/booth
static int do_server(int type)
{
	int fd = -1;
	int rv = -1;

	rv = setup(type);
	if (rv < 0)
		goto out;

	if (!daemonize) {
		if (daemon(0, 0) < 0) {
			perror("daemon error");
			exit(EXIT_FAILURE);
		}
	}

	/*
	  The lock cannot be obtained before the call to daemon(), otherwise
	  the lockfile would contain the pid of the parent, not the daemon.
	*/
	fd = lockfile();
	if (fd < 0)
		return fd;

	if (type == ARBITRATOR)
		log_info("BOOTH arbitrator daemon started");
	else if (type == SITE)
		log_info("BOOTH cluster site daemon started");

	set_scheduler();
	set_oom_adj(-16);

	rv = loop();

out:
	if (fd >= 0)
		unlink_lockfile(fd);

	return rv;
}