Exemple #1
0
        public void Start()
        {
            try
            {
                logger.Debug("FastAGIDaemon Starting");

                if (m_agiServerIPAddress == null || m_agiServerIPAddress.Trim().Length == 0)
                {
                    throw new ApplicationException("Could not start FastAGI service as no listening IP address was specified.");
                }
                else if (m_agiWorkerThreadsCount <= 0)
                {
                    throw new ApplicationException("Could not start FastAGI service as the number of worker threads is zero.");
                }

                IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Parse(m_agiServerIPAddress), m_agiServerPort);

                logger.Debug("Starting FastAGI socket on " + IPSocket.GetSocketString(localEndPoint));

                m_fastAGIServer = new TcpListener(localEndPoint);
                m_fastAGIServer.Server.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.DontLinger, true);
                m_fastAGIServer.Start();

                m_fastAGIQueueDaemon = new FastAGIQueueDaemon(m_queueAlertThreshold, m_queueMetricsFilePath, m_appMetricsFilePath, m_agiErrorAddress);
                m_fastAGIQueueDaemon.Start(m_agiWorkerThreadsCount, THREAD_NAME);

                while (!m_stopDaemon)
                {
                    Socket     fastAGIClient = m_fastAGIServer.AcceptSocket();
                    IPEndPoint connEndPoint  = (IPEndPoint)fastAGIClient.RemoteEndPoint;

                    logger.Debug("new connection from " + IPSocket.GetSocketString(connEndPoint));

                    m_fastAGIQueueDaemon.AddNewConnection(fastAGIClient);
                }

                logger.Debug("FastAGI Deamon Stopping.");
            }
            catch (Exception excp)
            {
                logger.Error("Exception FastAGIDaemon Start. " + excp.Message);
            }
        }
		public void Start()
		{
			try
			{
				logger.Debug("FastAGIDaemon Starting");

                if (m_agiServerIPAddress == null || m_agiServerIPAddress.Trim().Length == 0)
                {
                    throw new ApplicationException("Could not start FastAGI service as no listening IP address was specified.");
                }
                else if (m_agiWorkerThreadsCount <= 0)
                {
                    throw new ApplicationException("Could not start FastAGI service as the number of worker threads is zero.");
                }

				IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Parse(m_agiServerIPAddress), m_agiServerPort);

				logger.Debug("Starting FastAGI socket on " + IPSocket.GetSocketString(localEndPoint));

				m_fastAGIServer = new TcpListener(localEndPoint);
                m_fastAGIServer.Server.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.DontLinger, true);
                m_fastAGIServer.Start();

                m_fastAGIQueueDaemon = new FastAGIQueueDaemon(m_queueAlertThreshold, m_queueMetricsFilePath, m_appMetricsFilePath, m_agiErrorAddress);
                m_fastAGIQueueDaemon.Start(m_agiWorkerThreadsCount, THREAD_NAME);

                while (!m_stopDaemon)
				{
					Socket fastAGIClient = m_fastAGIServer.AcceptSocket();
					IPEndPoint connEndPoint = (IPEndPoint)fastAGIClient.RemoteEndPoint;

					logger.Debug("new connection from " + IPSocket.GetSocketString(connEndPoint));

                    m_fastAGIQueueDaemon.AddNewConnection(fastAGIClient);
				}

                logger.Debug("FastAGI Deamon Stopping.");
                
			}
			catch(Exception excp)
			{
                logger.Error("Exception FastAGIDaemon Start. " + excp.Message);
			}
		}