Ejemplo n.º 1
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        /// <param name="args">The arguments passed, if any.</param>
        static void Main(string[] args)
        {
            // Configure the thread pool's minimum threads
            ThreadPool.SetMinThreads(128, 128);

            var version = Assembly.GetEntryAssembly().GetName().Version;

            Console.Title           = "Dache Cache Host " + version;
            Console.ForegroundColor = ConsoleColor.Cyan;

            Console.WriteLine("INFO: Loading Settings...");
            Console.WriteLine();

            if (!ConfigureCacheHostEngine())
            {
                return;
            }

            Console.WriteLine("INFO: Starting " + Console.Title + "...");

            _cacheHostEngine.Start();

            Console.WriteLine("INFO: Started Successfully");
            Console.WriteLine();

            new AutoResetEvent(false).WaitOne();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Fires when the windows service starts.
        /// </summary>
        /// <param name="args">The arguments passed, if any.</param>
        protected override void OnStart(string[] args)
        {
            _logger.Info("Cache Host is starting", "Cache Host is starting");

            // Configure the thread pool's minimum threads
            ThreadPool.SetMinThreads(128, 128);

            _logger.Info("Cache Host is starting", "Verifying settings");

            try
            {
                // Instantiate the cache host engine
                _cacheHostEngine = new CacheHostEngine(CacheHostConfigurationSection.Settings);
            }
            catch (Exception ex)
            {
                // The inner exception has the actual details of the configuration error
                if (ex.InnerException != null && ex.InnerException.Message != null && ex.InnerException.Message.StartsWith("The value for the property", StringComparison.OrdinalIgnoreCase))
                {
                    ex = ex.InnerException;
                }

                // Log the error
                _logger.Error("Cache Host failed to start", ex.Message);

                // Stop the service
                Stop();
            }

            _logger.Info("Cache Host is starting", "Settings verified successfully");

            _cacheHostEngine.Start();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Fires when the windows service starts.
        /// </summary>
        /// <param name="args">The arguments passed, if any.</param>
        protected override void OnStart(string[] args)
        {
            _logger.Info("Cache Host is starting", "Cache Host is starting");

            // Configure the thread pool's minimum threads
            ThreadPool.SetMinThreads(128, 128);

            _logger.Info("Cache Host is starting", "Verifying settings");

            try
            {
                // Gather settings
                var configuration = CacheHostConfigurationSection.Settings;

                var port = configuration.Port;
                var physicalMemoryLimitPercentage = configuration.CacheMemoryLimitPercentage;
                var maximumConnections            = configuration.MaximumConnections;

                // Configure the performance counter data manager
                var performanceDataManager = new PerformanceCounterPerformanceDataManager(port);

                // Determine the MemCache to use
                IMemCache memCache;
                var       memoryCache = new MemCache(physicalMemoryLimitPercentage, performanceDataManager);

                if (configuration.StorageProvider == typeof(GZipMemCache))
                {
                    memCache = new GZipMemCache(memoryCache);
                }
                else
                {
                    memCache = memoryCache;
                }

                // Instantiate the cache host engine
                _cacheHostEngine = new CacheHostEngine(memCache, _logger, port, physicalMemoryLimitPercentage, maximumConnections);
            }
            catch (Exception ex)
            {
                // The inner exception has the actual details of the configuration error
                if (ex.InnerException != null && ex.InnerException.Message != null && ex.InnerException.Message.StartsWith("The value for the property", StringComparison.OrdinalIgnoreCase))
                {
                    ex = ex.InnerException;
                }

                // Log the error
                _logger.Error("Cache Host failed to start", ex.Message);

                // Stop the service
                Stop();
            }

            _logger.Info("Cache Host is starting", "Settings verified successfully");

            _cacheHostEngine.Start();
        }