Пример #1
0
pid_t
wd_main(int fork_wait_time)
{
	int i;

	if (!pool_config->use_watchdog)
		return 0;

	/* check pool_config data */
	wd_check_config();

	/* initialize */
	wd_init();

	wd_ppid = getpid();

	/* launch child process */
	child_pid = wd_child(1);

	if (!strcmp(pool_config->wd_lifecheck_method, MODE_HEARTBEAT))
	{
		for (i = 0; i < pool_config->num_hb_if; i++)
		{
			/* heartbeat receiver process */
			hb_receiver_pid[i] = wd_hb_receiver(1, &(pool_config->hb_if[i]));

			/* heartbeat sender process */
			hb_sender_pid[i] = wd_hb_sender(1, &(pool_config->hb_if[i]));
		}
	}

	/* fork lifecheck process*/
	lifecheck_pid = fork_a_lifecheck(fork_wait_time);

	return lifecheck_pid;
}
Пример #2
0
pid_t
wd_main(int fork_wait_time)
{
	int status = WD_INIT;
	int i;

	if (!pool_config->use_watchdog)
	{
		return 0;
	}

	/* check pool_config data */
	status = wd_check_config();
	if (status != WD_OK)
	{
		pool_error("watchdog: wd_check_config failed");
		return 0;
	}

	/* initialize */
	status = wd_init();
	if (status != WD_OK)
	{
		pool_error("watchdog: wd_init failed");
		return 0;
	}

	wd_ppid = getpid();

	/* launch child process */
	child_pid = wd_child(1);
	if (child_pid < 0 )
	{
		pool_error("launch wd_child failed");
		return 0;
	}

	if (!strcmp(pool_config->wd_lifecheck_method, MODE_HEARTBEAT))
	{
		for (i = 0; i < pool_config->num_hb_if; i++)
		{
			/* heartbeat receiver process */
			hb_receiver_pid[i] = wd_hb_receiver(1, pool_config->hb_if[i]);
			if (hb_receiver_pid[i] < 0 )
			{
				pool_error("launch wd_hb_receiver failed");
				return hb_receiver_pid[i];
			}

			/* heartbeat sender process */
			hb_sender_pid[i] = wd_hb_sender(1, pool_config->hb_if[i]);
			if (hb_sender_pid[i] < 0 )
			{
				pool_error("launch wd_hb_sender failed");
				return hb_sender_pid[i];
			}
		}
	}

	/* fork lifecheck process*/
	lifecheck_pid = fork_a_lifecheck(fork_wait_time);
	if (lifecheck_pid < 0 )
	{
		pool_error("launch lifecheck process failed");
		return 0;
	}

	return lifecheck_pid;
}