Example #1
0
int main(int argc, char **argv) {
	struct main_context ctx;
	int idx=0;

	options(&argc, &argv);
	init_everything();
	create_everything(&ctx);

	ilog(LOG_INFO, "Startup complete, version %s", RTPENGINE_VERSION);

	thread_create_detach(sighandler, NULL);
	thread_create_detach(poller_timer_loop, ctx.p);

	if (graphite_ip)
		thread_create_detach(graphite_loop, ctx.m);
	thread_create_detach(ice_thread_run, NULL);

	if (num_threads < 1) {
#ifdef _SC_NPROCESSORS_ONLN
		num_threads = sysconf( _SC_NPROCESSORS_ONLN );
#endif
		if (num_threads < 1)
			num_threads = 4;
	}

	for (;idx<num_threads;++idx) {
		thread_create_detach(poller_loop, ctx.p);
	}

	while (!g_shutdown) {
		usleep(100000);
		threads_join_all(0);
	}

	threads_join_all(1);

	ilog(LOG_INFO, "Version %s shutting down", RTPENGINE_VERSION);

	return 0;
}
Example #2
0
int main(int argc, char **argv) {
	struct main_context ctx;

	options(&argc, &argv);
	init_everything();
	create_everything(&ctx);

	ilog(LOG_INFO, "Startup complete, version %s", RTPENGINE_VERSION);

	thread_create_detach(sighandler, NULL);
	thread_create_detach(timer_loop, ctx.p);
	thread_create_detach(poller_loop, ctx.p);
	thread_create_detach(poller_loop, ctx.p);
	thread_create_detach(poller_loop, ctx.p);
	thread_create_detach(poller_loop, ctx.p);

	while (!global_shutdown) {
		usleep(100000);
		threads_join_all(0);
	}

	threads_join_all(1);

	ilog(LOG_INFO, "Version %s shutting down", RTPENGINE_VERSION);

	return 0;
}
Example #3
0
int main(int argc, char **argv) {
	struct main_context ctx;
	int idx=0;

	options(&argc, &argv);
	init_everything();
	create_everything(&ctx);

	ilog(LOG_INFO, "Startup complete, version %s", RTPENGINE_VERSION);

	thread_create_detach(sighandler, NULL);
	thread_create_detach(poller_timer_loop, ctx.p);

	if (!is_addr_unspecified(&redis_ep.address))
		thread_create_detach(redis_notify_loop, ctx.m);

	if (!is_addr_unspecified(&graphite_ep.address))
		thread_create_detach(graphite_loop, ctx.m);

	thread_create_detach(ice_thread_run, NULL);

	if (num_threads < 1) {
#ifdef _SC_NPROCESSORS_ONLN
		num_threads = sysconf( _SC_NPROCESSORS_ONLN );
#endif
		if (num_threads < 1)
			num_threads = 4;
	}

	for (;idx<num_threads;++idx) {
		thread_create_detach(poller_loop, ctx.p);
	}

	while (!g_shutdown) {
		usleep(100000);
		threads_join_all(0);
	}

	redis_notify_event_base_action(ctx.m, EVENT_BASE_LOOPBREAK);

	threads_join_all(1);

	ilog(LOG_INFO, "Version %s shutting down", RTPENGINE_VERSION);

	return 0;
}
Example #4
0
int main(int argc, char **argv) {
	int idx;

	early_init();
	options(&argc, &argv);
	init_everything();
	create_everything();
	fill_initial_rtpe_cfg(&initial_rtpe_config);

	ilog(LOG_INFO, "Startup complete, version %s", RTPENGINE_VERSION);

	thread_create_detach(sighandler, NULL);
	thread_create_detach_prio(poller_timer_loop, rtpe_poller, rtpe_config.idle_scheduling, rtpe_config.idle_priority);
	thread_create_detach_prio(load_thread, NULL, rtpe_config.idle_scheduling, rtpe_config.idle_priority);

	if (!is_addr_unspecified(&rtpe_config.redis_ep.address))
		thread_create_detach(redis_notify_loop, NULL);

	if (!is_addr_unspecified(&rtpe_config.graphite_ep.address))
		thread_create_detach(graphite_loop, NULL);

	thread_create_detach(ice_thread_run, NULL);

	if (rtpe_config.num_threads < 1) {
#ifdef _SC_NPROCESSORS_ONLN
		rtpe_config.num_threads = sysconf( _SC_NPROCESSORS_ONLN ) + 3;
#endif
		if (rtpe_config.num_threads <= 1)
			rtpe_config.num_threads = 4;
	}

	service_notify("READY=1\n");

	for (idx = 0; idx < rtpe_config.num_threads; ++idx)
		thread_create_detach_prio(poller_loop, rtpe_poller, rtpe_config.scheduling, rtpe_config.priority);

	if (rtpe_config.media_num_threads < 0)
		rtpe_config.media_num_threads = rtpe_config.num_threads;
	for (idx = 0; idx < rtpe_config.media_num_threads; ++idx) {
#ifdef WITH_TRANSCODING
		thread_create_detach_prio(media_player_loop, NULL, rtpe_config.scheduling, rtpe_config.priority);
#endif
		thread_create_detach_prio(send_timer_loop, NULL, rtpe_config.scheduling, rtpe_config.priority);
	}


	while (!rtpe_shutdown) {
		usleep(100000);
		threads_join_all(0);
	}

	service_notify("STOPPING=1\n");

	if (!is_addr_unspecified(&rtpe_config.redis_ep.address)) {
		redis_notify_event_base_action(EVENT_BASE_LOOPBREAK);
		redis_notify_event_base_action(EVENT_BASE_FREE);
	}

	threads_join_all(1);

	ilog(LOG_INFO, "Version %s shutting down", RTPENGINE_VERSION);

	return 0;
}