Пример #1
0
int main(int argc, char * argv[])
#endif
{
	initStartTime();

	printf("ObjectScript FastCGI Process Manager %s\n", OS_FCGI_VERSION);
	printf("%s\n", OS_COPYRIGHT);
	printf("%s\n", OS_OPENSOURCE);

	if(FCGX_Init()){
// #ifdef _MSC_VER
		printf("Error: initialization is failed\n");
// #endif
		exit(1); 
	}

	int threads;
	{
		OS * os = OS::create();
#ifdef _MSC_VER
		const char * config_flename = "conf\\etc\\os-fcgi\\conf.os";
		if(!os->isFileExist(config_flename)){
			config_flename = "..\\..\\conf\\etc\\os-fcgi\\conf.os";
			// os->isFileExist(config_flename);
		}
#else
		const char * config_flename = "/etc/os-fcgi/conf.os";
#endif
		os->require(config_flename, false, 1);
		threads =			(os->getProperty(-1, "threads"),	os->popInt());
		OS::String listen = (os->getProperty(-1, "listen"),		os->popString(":9000"));
		os->release();

		int listen_queue_backlog = 400;
		listen_socket = FCGX_OpenSocket(listen, listen_queue_backlog);
		if(listen_socket < 0){
			printf("Error: listen address is incorrect %s\n", listen.toChar());
			// log("listen_socket < 0 \n");
			exit(1);
		}
// #ifdef _MSC_VER
		printf("listen: %s\n", listen.toChar());
// #endif
	}

#ifndef _MSC_VER
	const int MAX_THREAD_COUNT = 64;
	if(threads < 1){
		threads = 1;
	}else if(threads > MAX_THREAD_COUNT){ 
		threads = MAX_THREAD_COUNT;
	}
	printf("threads: %d\n", threads);
	demonize();
	
	pthread_t id[MAX_THREAD_COUNT];
	for(int i = 1; i < threads; i++){
        pthread_create(&id[i], NULL, doit, NULL);
	}
#else
	threads = 1;
	printf("threads: %d\n", threads);
#endif
	doit(NULL);

	return 0;
}