示例#1
0
        /// <summary>
        /// Stops the service immediately, terminating any user activity.
        /// </summary>
        public void Stop()
        {
            lock (syncLock)
            {
                if (state == ServiceState.Stopped)
                {
                    return;
                }

                SysLog.LogInformation("Authentication Service Stop");
                SysLog.Flush();

                base.Close();
                state = ServiceState.Stopped;

                if (handler != null)
                {
                    handler.Stop();
                    handler = null;
                }

                if (router != null)
                {
                    router.Stop();
                    router = null;
                }

                Program.PerfCounters.Zero();
            }
        }
示例#2
0
        /// <summary>
        /// Stops the service immediately, terminating any user activity.
        /// </summary>
        public void Stop()
        {
            lock (syncLock) {
                if (state == ServiceState.Stopped)
                {
                    return;
                }

                SysLog.LogInformation("GeoTracker Service Stop");
                SysLog.Flush();

                base.Close();
                state = ServiceState.Stopped;
            }

            if (node != null)
            {
                node.Stop();
                node = null;
            }

            if (router != null)
            {
                router.Stop();
                router = null;
            }

            Program.PerfCounters.Zero();
        }
示例#3
0
        public void FlightRecorder_PassThru_SysLogProvider()
        {
            // Verify that the ISysLogProvider implementation works.

            Queue <FlightEvent> queue       = new Queue <FlightEvent>();
            ISysLogProvider     orgProvider = SysLog.LogProvider;

            try
            {
                FlightEvent flightEvent;

                using (var recorder = new FlightRecorder(evt => queue.Enqueue(evt)))
                {
                    SysLog.LogProvider = recorder;

                    SysLog.LogError("Test Error");
                    SysLog.LogWarning("Test Warning");
                    SysLog.LogInformation("Test Information");
                    SysLog.Flush();

                    Assert.AreEqual(3, queue.Count);

                    flightEvent = queue.Dequeue();
                    Assert.AreEqual("SysLog:Error", flightEvent.Operation);
                    Assert.IsTrue(flightEvent.Details.Contains("Test Error"));
                    Assert.IsTrue(flightEvent.IsError);

                    flightEvent = queue.Dequeue();
                    Assert.AreEqual("SysLog:Warning", flightEvent.Operation);
                    Assert.IsTrue(flightEvent.Details.Contains("Test Warning"));
                    Assert.IsFalse(flightEvent.IsError);

                    flightEvent = queue.Dequeue();
                    Assert.AreEqual("SysLog:Information", flightEvent.Operation);
                    Assert.IsTrue(flightEvent.Details.Contains("Test Information"));
                    Assert.IsFalse(flightEvent.IsError);

                    // Verify that system events actually serialize exception
                    // and stack trace related information.

                    try
                    {
                        throw new AssertException();
                    }
                    catch (Exception e)
                    {
                        SysLog.LogException(e);
                        SysLog.Flush();

                        flightEvent = queue.Dequeue();
                        Assert.AreEqual("SysLog:Exception", flightEvent.Operation);
                        Assert.IsTrue(flightEvent.Details.Contains("AssertException"));
                    }
                }
            }
            finally
            {
                SysLog.LogProvider = orgProvider;
            }
        }
示例#4
0
        /// <summary>
        /// Stops the service immediately, terminating any user activity.
        /// </summary>
        public void Stop()
        {
            lock (syncLock)
            {
                if (state == ServiceState.Stopped)
                {
                    return;
                }

                SysLog.LogInformation("Dynamic DNS Client Stop");
                SysLog.Flush();

                base.Close();
                state = ServiceState.Stopped;
            }

            if (router != null)
            {
                client.Close();
                client = null;

                router.Stop();
                router = null;
            }

            Program.PerfCounters.Zero();
        }
示例#5
0
        /// <summary>
        /// Handles the UI timer events.
        /// </summary>
        /// <param name="state"></param>
        /// <param name="status"></param>
        private void OnUITimer(ServiceState state, string status)
        {
            bool enableStart    = false;
            bool enableStop     = false;
            bool enableShutdown = false;

            SetStatus(state.ToString());

            switch (state)
            {
            case ServiceState.Stopped:

                enableStart = true;
                SysLog.Flush();
                break;

            case ServiceState.Running:

                enableStop     = true;
                enableShutdown = true;
                break;

            case ServiceState.Shutdown:

                enableStop = true;
                break;
            }

            startButton.Enabled    = enableStart;
            stopButton.Enabled     = enableStop;
            shutDownButton.Enabled = enableShutdown;
            displayStatus.Text     = status;
        }
示例#6
0
        /// <summary>
        /// Stops the service immediately, terminating any user activity.
        /// </summary>
        public void Stop()
        {
            lock (syncLock)
            {
                if (state == ServiceState.Stopped)
                {
                    return;
                }

                SysLog.LogInformation("Config Service Stop");
                SysLog.Flush();

                base.Close();
                state = ServiceState.Stopped;

                if (router != null)
                {
                    handler.Stop();
                    handler = null;

                    router.Stop();
                    router = null;
                }
            }
        }
示例#7
0
        /// <summary>
        /// Stops the service immediately, terminating any user activity.
        /// </summary>
        public void Stop()
        {
            lock (syncLock)
            {
                if (state == ServiceState.Stopped)
                {
                    return;
                }

                SysLog.LogInformation("NeonSwitch Stop");
                SysLog.Flush();

                base.Close();
                state = ServiceState.Stopped;

                if (bkTimer != null)
                {
                    bkTimer.Dispose();
                    bkTimer = null;
                }

                if (router != null)
                {
                    router.Stop();
                    router = null;
                }
            }
        }
示例#8
0
 /// <summary>
 /// Stop this service.
 /// </summary>
 protected override void OnStop()
 {
     try
     {
         service.Stop();
         SysLog.Flush();
     }
     catch (Exception e)
     {
         SysLog.LogException(e);
     }
 }
示例#9
0
        /// <summary>
        /// Stops the service immediately, terminating any user activity.
        /// </summary>
        public void Stop()
        {
            lock (syncLock)
            {
                if (state == ServiceState.Stopped)
                {
                    return;
                }

                SysLog.LogInformation("Broadcast Server Stop");
                SysLog.Flush();

                base.Close();
                state = ServiceState.Stopped;

                if (udpServer != null)
                {
                    udpServer.Close();
                    udpServer = null;
                }

                Program.PerfCounters.Zero();
            }
        }
示例#10
0
 /// <summary>
 /// Waits for the service to stop.
 /// </summary>
 /// <remarks>
 /// In real life, this will never return since the ServiceBase
 /// kills the process when it receives a stop command from a
 /// ServiceControl instance.
 /// </remarks>
 public void WaitForStop()
 {
     SysLog.Flush();
     Helper.WaitFor(() => service.State == ServiceState.Stopped, TimeSpan.FromMinutes(1));
 }