Exemplo n.º 1
0
 /// <summary>
 /// Releases unmanaged and - optionally - managed resources
 /// </summary>
 /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
 protected virtual void Dispose(bool disposing)
 {
     if (disposing && MonitoringServer != null)
     {
         MonitoringServer.Dispose();
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Stops mail server.
        /// </summary>
        public void Stop()
        {
            // Server isn't running, so do nothing.
            if (!m_Running)
            {
                return;
            }

            m_pSettingsTimer.Enabled = false;

            // Kill all running virtual servers
            foreach (VirtualServer server in m_pVirtualServers)
            {
                server.Stop();
            }
            m_pVirtualServers.Clear();

            // Kill management server
            m_pManagementServer.Dispose();
            m_pManagementServer = null;

            m_Running = false;

            // Logging stuff
            Logger.WriteLog(m_StartupPath + "Logs\\Server\\server.log", "//---- Server stopped " + DateTime.Now);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Starts the HTTP server used for monitoring.
 /// </summary>
 /// <param name="host">The host that publishes the monitoring server.</param>
 /// <param name="port">The port on which the server will listen.</param>
 /// <param name="auth">The user and password used for basic http authentication.</param>
 private void StartHttpServer(string host, int port, string[] auth)
 {
     // TODO: vladi: port this again, this will most likely not work
     this.httpMonitoringServer = new MonitoringServer(port, host, auth[0], auth[1]);
     this.httpMonitoringServer.HealthzRequested += new EventHandler <HealthzRequestEventArgs>(this.HttpMonitoringServer_HealthzRequested);
     this.httpMonitoringServer.VarzRequested    += new EventHandler <VarzRequestEventArgs>(this.HttpMonitoringServer_VarzRequested);
     this.httpMonitoringServer.Start();
 }
Exemplo n.º 4
0
 public void Start()
 {
     if (this.m_Running)
     {
         return;
     }
     this.m_ServersFileDate = DateTime.MinValue;
     this.m_pSettingsTimer_Elapsed(this, null);
     this.m_pSettingsTimer.Enabled = true;
     this.m_pManagementServer      = new MonitoringServer(this);
     this.m_pManagementServer.Start();
     this.m_Running   = true;
     this.m_StartTime = DateTime.Now;
 }
Exemplo n.º 5
0
 public void Stop()
 {
     if (!this.m_Running)
     {
         return;
     }
     this.m_pSettingsTimer.Enabled = false;
     foreach (VirtualServer current in this.m_pVirtualServers)
     {
         current.Stop();
     }
     this.m_pVirtualServers.Clear();
     this.m_pManagementServer.Dispose();
     this.m_pManagementServer = null;
     this.m_Running           = false;
     Logger.WriteLog(this.m_StartupPath + "Logs\\Server\\server.log", "//---- Server stopped " + DateTime.Now);
 }
Exemplo n.º 6
0
        /// <summary>
        /// Starts mail server.
        /// </summary>
        public void Start()
        {
            // Server is already running, so do nothing.
            if (m_Running)
            {
                return;
            }

            m_ServersFileDate = DateTime.MinValue;
            m_pSettingsTimer_Elapsed(this, null);
            m_pSettingsTimer.Enabled = true;

            // Start management server
            m_pManagementServer = new MonitoringServer(this);
            m_pManagementServer.Start();

            m_Running   = true;
            m_StartTime = DateTime.Now;
        }
Exemplo n.º 7
0
        /// <summary>
        /// Starts the HTTP server used for healthz and varz.
        /// </summary>
        private void StartHttpServer()
        {
            MonitoringServer = new MonitoringServer(this.Port, this.Host, this.Authentication[0], this.Authentication[1]);

            MonitoringServer.VarzRequested += delegate(object sender, VarzRequestEventArgs response)
            {
                try
                {
                    this.VarzLock.EnterWriteLock();
                    response.VarzMessage = JsonConvertibleObject.SerializeToJson(this.Varz);
                }
                finally
                {
                    this.VarzLock.ExitWriteLock();
                }
            };

            MonitoringServer.HealthzRequested += delegate(object sender, HealthzRequestEventArgs response)
            {
                response.HealthzMessage = this.Healthz;
            };

            MonitoringServer.Start();
        }