示例#1
0
 protected virtual Yield DeleteConfig(DreamContext context, DreamMessage request, Result <DreamMessage> response)
 {
     if (IsStarted)
     {
         _timerFactory.Dispose();
         yield return(Coroutine.Invoke(Stop, new Result()));
     }
     response.Return(DreamMessage.Ok());
     yield break;
 }
示例#2
0
 public void Dispose()
 {
     _disposed = true;
     _timerFactory.Dispose();
     if (!Directory.Exists(_tempDirectory))
     {
         return;
     }
     try {
         Directory.Delete(_tempDirectory, true);
     } catch (Exception e) {
         _log.Warn(string.Format("unable to delete cache directory '{0}': {1}", _tempDirectory, e.Message), e);
     }
 }
示例#3
0
        internal void EndShutdown()
        {
            if (_status != DekiInstanceStatus.STOPPING)
            {
                _log.WarnFormat("EndShutdown was attemped with instance in state {0}", _status);
                throw new InvalidOperationException("bad state");
            }

            // shut down task timer
            try {
                TimerFactory.Dispose();
            } catch (Exception e) {
                _log.Warn(string.Format("unable to shut down timerfactory for instance '{0}': {1}", Id, e.Message), e);
            }

            // shut down storage
            _log.DebugFormat("shutting down storage for '{0}'", Id);
            try {
                _storage.Dispose();
            } catch (Exception e) {
                _log.Warn(string.Format("unable to cleanly shut down storage for instance '{0}': {1}", Id, e.Message), e);
            }
            _storage = null;

            // shut down services
            _log.DebugFormat("shutting down services for '{0}'", Id);
            try {
                ServiceBL.StopServices();

                // reset instance fields
                RunningServices.Clear();
            } catch (Exception e) {
                _log.Warn(string.Format("unable to cleanly shut down services for instance '{0}': {1}", Id, e.Message), e);
            }

            // shutting down cache
            try {
                Cache.Dispose();
            } catch (Exception e) {
                _log.Warn(string.Format("unable to dispose the cache for instance '{0}': {1}", Id, e.Message), e);
            }

            // shutting down search cache
            try {
                SearchCache.Dispose();
            } catch (Exception e) {
                _log.Warn(string.Format("unable to dispose the search cache for instance '{0}': {1}", Id, e.Message), e);
            }

            // sending shut down event
            try {
                _eventSink.InstanceShutdown(DekiContext.Current.Now);
            } catch (Exception e) {
                _log.Warn(string.Format("unable to send the shutdown notification event for instance '{0}': {1}", Id, e.Message), e);
            }
            _eventSink = null;

            // unregister the instance to database mapping
            if (null != _sessionFactory)
            {
                try {
                    _sessionFactory.Dispose();
                } catch (Exception e) {
                    _log.Warn(string.Format("unable to cleanly shut down the session factory for instance '{0}': {1}", Id, e.Message), e);
                }
                _sessionFactory = null;
            }
            _log.DebugFormat("instance '{0}' stopped", Id);
            _status = DekiInstanceStatus.STOPPED;
        }