示例#1
0
        public ScriptHostManager(ScriptHostConfiguration config,
                                 ScriptSettingsManager settingsManager,
                                 IScriptHostFactory scriptHostFactory,
                                 IScriptEventManager eventManager   = null,
                                 IScriptHostEnvironment environment = null)
        {
            _environment       = environment ?? this;
            _config            = config;
            _settingsManager   = settingsManager;
            _scriptHostFactory = scriptHostFactory;

            EventManager = eventManager ?? new ScriptEventManager();

            _structuredLogWriter = new StructuredLogWriter(EventManager, config.RootLogPath);
        }
        public ScriptHostManager(ScriptHostConfiguration config,
                                 ScriptSettingsManager settingsManager,
                                 IScriptHostFactory scriptHostFactory,
                                 IScriptEventManager eventManager              = null,
                                 IScriptHostEnvironment environment            = null,
                                 ILoggerProviderFactory loggerProviderFactory  = null,
                                 HostPerformanceManager hostPerformanceManager = null)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }
            if (settingsManager == null)
            {
                throw new ArgumentNullException(nameof(settingsManager));
            }

            scriptHostFactory      = scriptHostFactory ?? new ScriptHostFactory();
            _environment           = environment ?? this;
            _config                = config;
            _settingsManager       = settingsManager;
            _scriptHostFactory     = scriptHostFactory;
            _loggerProviderFactory = loggerProviderFactory;

            EventManager = eventManager ?? new ScriptEventManager();

            _structuredLogWriter = new StructuredLogWriter(EventManager, config.RootLogPath);
            _performanceManager  = hostPerformanceManager ?? new HostPerformanceManager(settingsManager, _config.HostHealthMonitor);

            if (config.FileWatchingEnabled && !settingsManager.FileSystemIsReadOnly)
            {
                // We only setup a subscription here as the actual ScriptHost will create the publisher
                // when initialized.
                _fileEventSubscription = EventManager.OfType <FileEvent>()
                                         .Where(f => string.Equals(f.Source, EventSources.ScriptFiles, StringComparison.Ordinal))
                                         .Subscribe(e => OnScriptFileChanged(null, e.FileChangeArguments));
            }

            if (ShouldMonitorHostHealth)
            {
                _healthCheckWindow    = new SlidingWindow <bool>(_config.HostHealthMonitor.HealthCheckWindow);
                _hostHealthCheckTimer = new Timer(OnHostHealthCheckTimer, null, TimeSpan.Zero, _config.HostHealthMonitor.HealthCheckInterval);
            }
        }
        public ScriptHostManager(ScriptHostConfiguration config,
                                 ScriptSettingsManager settingsManager,
                                 IScriptHostFactory scriptHostFactory,
                                 IScriptEventManager eventManager              = null,
                                 IScriptHostEnvironment environment            = null,
                                 ILoggerFactoryBuilder loggerFactoryBuilder    = null,
                                 HostPerformanceManager hostPerformanceManager = null)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }
            if (settingsManager == null)
            {
                throw new ArgumentNullException(nameof(settingsManager));
            }

            scriptHostFactory     = scriptHostFactory ?? new ScriptHostFactory();
            _environment          = environment ?? this;
            _config               = config;
            _settingsManager      = settingsManager;
            _scriptHostFactory    = scriptHostFactory;
            _loggerFactoryBuilder = loggerFactoryBuilder;

            EventManager = eventManager ?? new ScriptEventManager();

            _structuredLogWriter = new StructuredLogWriter(EventManager, config.RootLogPath);
            _performanceManager  = hostPerformanceManager ?? new HostPerformanceManager(settingsManager);

            // TEMP : temporarily disabling this until the feature is improved
            bool periodicHealthCheckEnabled = false;

            if (periodicHealthCheckEnabled && config.HostHealthMonitorEnabled && settingsManager.IsAzureEnvironment)
            {
                _hostHealthCheckTimer = new Timer(OnHostHealthCheckTimer, null, TimeSpan.Zero, hostHealthCheckInterval);
            }
        }