public WebScriptHostManager(ScriptHostConfiguration config,
                                    ISecretManagerFactory secretManagerFactory,
                                    IScriptEventManager eventManager,
                                    ScriptSettingsManager settingsManager,
                                    WebHostSettings webHostSettings,
                                    IWebJobsRouter router,
                                    ILoggerFactory loggerFactory,
                                    IScriptHostFactory scriptHostFactory = null,
                                    ISecretsRepositoryFactory secretsRepositoryFactory = null,
                                    HostPerformanceManager hostPerformanceManager      = null,
                                    ILoggerProviderFactory loggerProviderFactory       = null,
                                    int hostTimeoutSeconds = 30,
                                    int hostPollingIntervalMilliseconds = 500)
            : base(config, settingsManager, scriptHostFactory, eventManager, environment: null,
                   hostPerformanceManager: hostPerformanceManager, loggerProviderFactory: loggerProviderFactory)
        {
            _config = config;

            _metricsLogger      = new WebHostMetricsLogger();
            _exceptionHandler   = new WebScriptHostExceptionHandler(this);
            _webHostSettings    = webHostSettings;
            _settingsManager    = settingsManager;
            _hostTimeoutSeconds = hostTimeoutSeconds;
            _hostRunningPollIntervalMilliseconds = hostPollingIntervalMilliseconds;
            _router = router;

            config.IsSelfHost = webHostSettings.IsSelfHost;

            secretsRepositoryFactory = secretsRepositoryFactory ?? new DefaultSecretsRepositoryFactory();
            var secretsRepository = secretsRepositoryFactory.Create(settingsManager, webHostSettings, config);

            _secretManager = secretManagerFactory.Create(settingsManager, loggerFactory.CreateLogger(ScriptConstants.LogCategoryHostGeneral), secretsRepository);

            _bindingWebHookProvider = new WebJobsSdkExtensionHookProvider(_secretManager);
        }
Esempio n. 2
0
 public ScriptHost Create(
     IScriptHostEnvironment environment,
     IScriptEventManager eventManager,
     ScriptSettingsManager settingsManager,
     ScriptHostConfiguration config,
     ILoggerProviderFactory loggerProviderFactory)
 {
     return(new ScriptHost(environment, eventManager, config, settingsManager, loggerProviderFactory));
 }
 public ScriptHostManager(
     ScriptHostConfiguration config,
     IScriptEventManager eventManager              = null,
     IScriptHostEnvironment environment            = null,
     ILoggerProviderFactory loggerProviderFactory  = null,
     HostPerformanceManager hostPerformanceManager = null)
     : this(config, ScriptSettingsManager.Instance, new ScriptHostFactory(), eventManager, environment, loggerProviderFactory, hostPerformanceManager)
 {
 }
        public WebHostResolver(ScriptSettingsManager settingsManager, ISecretManagerFactory secretManagerFactory,
                               IScriptEventManager eventManager, WebHostSettings settings, IWebJobsRouter router, ILoggerProviderFactory loggerProviderFactory,
                               ILoggerFactory loggerFactory)
        {
            _settingsManager      = settingsManager;
            _secretManagerFactory = secretManagerFactory;
            _eventManager         = eventManager;
            _router   = router;
            _settings = settings;

            // _loggerProviderFactory is used for creating the LoggerFactory for each ScriptHost
            _loggerProviderFactory = loggerProviderFactory;

            // _loggerFactory is used when there is no host available.
            _loggerFactory = loggerFactory;
        }
        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);
            }
        }
Esempio n. 6
0
 public BlipCliLogger(ILoggerProviderFactory loggerProviderFactory)
 {
     _mininumLogLevel       = LogLevel.Warning;
     _loggerProviderFactory = loggerProviderFactory;
 }
            public ScriptHost Create(IScriptHostEnvironment environment, IScriptEventManager eventManager, ScriptSettingsManager settingsManager, ScriptHostConfiguration config, ILoggerProviderFactory loggerProviderFactory)
            {
                if (Throw)
                {
                    throw new Exception("Kaboom!");
                }

                var mockMetricsLogger = new Mock <IMetricsLogger>(MockBehavior.Strict);

                config.HostConfig.AddService <IMetricsLogger>(mockMetricsLogger.Object);
                mockMetricsLogger.Setup(p => p.BeginEvent(It.IsAny <string>(), It.IsAny <string>())).Returns(new object());
                mockMetricsLogger.Setup(p => p.EndEvent(It.IsAny <object>()));
                mockMetricsLogger.Setup(p => p.LogEvent(It.IsAny <string>(), It.IsAny <string>()));
                mockMetricsLogger.Setup(p => p.LogEvent(It.IsAny <MetricEvent>()));

                return(new ScriptHost(environment, eventManager, config, settingsManager, loggerProviderFactory));
            }
 public MockScriptHostManager(ScriptHostConfiguration config, ILoggerProviderFactory loggerProviderFactory)
     : base(config, new Mock <IScriptEventManager>().Object, loggerProviderFactory: loggerProviderFactory)
 {
 }