Ejemplo n.º 1
0
void CL_Service_Unix::service_thread_main(std::vector<CL_String> args)
{
	service_start(args);
	while (true)
	{
		int wakeup_reason = CL_Event::wait(stop_event, reload_event);
		if (wakeup_reason == 1)
			service_reload();
		else
			break;
	}
	service_stop();
}
Ejemplo n.º 2
0
/* Singing and dancing ... */
static void svc_dance(svc_t *svc)
{
	svc_cmd_t cmd = service_enabled(svc, 0, NULL);

	if (svc->pid) {
		if (SVC_STOP == cmd)
			service_stop(svc);
		else if (SVC_RELOAD == cmd)
			service_reload(svc);
	} else {
		if (SVC_START == cmd || SVC_RELOAD == cmd)
			service_start(svc);
	}
}
Ejemplo n.º 3
0
void Service_Unix::service_thread_main(std::vector<std::string> args)
{
	service_start(args);
	while (true)
	{
		std::unique_lock<std::mutex> lock(mutex);
		event_condition.wait(lock, [&]() { return stop_flag || reload_flag; });

		if (stop_flag)
			break;

		reload_flag = false;
		service_reload();
	}
	service_stop();
}
Ejemplo n.º 4
0
int Service_Win32::run_debug(std::vector<std::string> args)
{
	debug_mode = true;
	SetConsoleCtrlHandler(&Service_Win32::control_handler, TRUE);

	service_start(args);
	while (true)
	{
		std::unique_lock<std::mutex> lock(mutex);
		event_condition.wait(lock, [&]() { return stop_flag || reload_flag; });

		if (stop_flag)
			break;

		reload_flag = false;
		service_reload();
	}
	service_stop();
	return 0;
}