/// <summary>
        /// Creates and runs a distributed cache service
        /// </summary>
        /// <exception cref="CacheException">thrown when cache startup fails</exception>
        public static async Task RunAsync(DistributedCacheServiceArguments arguments)
        {
            // Switching to another thread.
            await Task.Yield();

            var host   = arguments.Host;
            var logger = arguments.Logger;

            var factory = new ContentServerFactory(arguments);

            // await _lifetimeManager.StartingService();
            await host.OnStartingServiceAsync();

            using (var server = factory.Create())
            {
                var context = new Context(logger);

                try
                {
                    // Removed this, because it is kind-of useless...
                    // _serviceHealthyAction(false);

                    var startupResult = await server.StartupAsync(context);

                    if (!startupResult)
                    {
                        throw new CacheException(startupResult.ToString());
                    }

                    // _serviceHealthyAction(true);
                    host.OnStartedService();

                    logger.Info("Service started");

                    await arguments.Cancellation.WaitForCancellationAsync();

                    logger.Always("Exit event set");
                }
                finally
                {
                    var        timeoutInMinutes = arguments?.Configuration?.DistributedContentSettings?.MaxShutdownDurationInMinutes ?? 30;
                    BoolResult result           = await ShutdownWithTimeout(context, server, TimeSpan.FromMinutes(timeoutInMinutes));

                    if (!result)
                    {
                        logger.Warning("Failed to shutdown local content server: {0}", result);
                    }

                    // await _lifetimeManager.TeardownCompleted();
                    host.OnTeardownCompleted();
                }
            }
        }
        /// <summary>
        /// Constructor for the ServerSessionManager, calls the
        /// tracelistener and creates a list for telemetry subscribers.
        /// </summary>
        public ServerSessionManager(ICommunicator communicator)
        {
            _contentServer        = ContentServerFactory.GetInstance();
            _sessionData          = new SessionData();
            _serializer           = new Serializer();
            _telemetrySubscribers = new List <ITelemetryNotifications>();

            Session session = new();

            session.TraceListener();

            userCount        = 0;
            moduleIdentifier = "serverSessionManager";

            _communicator = communicator;
            _communicator.Subscribe(moduleIdentifier, this);
        }