Пример #1
0
        /// <summary>
        /// Load the status.
        /// </summary>
        private void LoadStatus()
        {
            var statusPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
                                          "var", "status.xml");

            try {
                Log.Debug("Trying to load status from [{0}]", statusPath);
                _status = ServiceStatus.Deserialize(statusPath, _config);
                Log.Debug("Loaded status from [{0}]", statusPath);
            }
            catch (Exception ex) {
                Log.Error("loading status XML from [{0}] failed: {1} {2}",
                          statusPath, ex.Message, ex.StackTrace);
                // this should terminate the service process:
                throw new Exception("Error loading status.");
            }

            // now check the clean-shutdown status and send a notification if it was not true,
            // then set it to false while the service is running until it is properly
            // shut down via the OnStop() method:
            if (_status.CleanShutdown == false)
            {
                Log.Error("WARNING: {0} was not shut down properly last time!\n\nThis could " +
                          "indicate the computer has crashed or was forcefully shut off.", ServiceName);
            }
            _status.CleanShutdown = false;
        }
Пример #2
0
        /// <summary>
        /// Read (or re-read) the service status file if it has changed since last time.
        /// </summary>
        private static void UpdateStatusInformation()
        {
            if (!_statusFileChanged)
            {
                return;
            }

            Log.Trace("Status file was updated, trying to re-read...");
            _status            = ServiceStatus.Deserialize(_statusFile, _config);
            _statusFileChanged = false;
            _statusChanged     = true;
        }
Пример #3
0
        /// <summary>
        /// Load the status.
        /// </summary>
        private void LoadStatus()
        {
            var statusPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
                                          "var", "status.xml");

            try {
                Log.Debug("Trying to load status from [{0}]", statusPath);
                _status = ServiceStatus.Deserialize(statusPath, _config);
                Log.Debug("Loaded status from [{0}]", statusPath);
            }
            catch (Exception ex) {
                Log.Error("loading status XML from [{0}] failed: {1} {2}",
                          statusPath, ex.Message, ex.StackTrace);
                // this should terminate the service process:
                throw new Exception("Error loading status.");
            }
        }