public ScriptHost Create(
     IScriptHostEnvironment environment,
     IScriptEventManager eventManager,
     ScriptSettingsManager settingsManager,
     ScriptHostConfiguration config,
     ILoggerFactoryBuilder loggerFactoryBuilder)
 {
     return(ScriptHost.Create(environment, eventManager, config, settingsManager, loggerFactoryBuilder));
 }
Exemplo n.º 2
0
 public WebHostResolver(ScriptSettingsManager settingsManager, ISecretManagerFactory secretManagerFactory,
                        IScriptEventManager eventManager, WebHostSettings settings, IWebJobsRouter router, ILoggerFactoryBuilder loggerFactoryBuilder)
 {
     _settingsManager      = settingsManager;
     _secretManagerFactory = secretManagerFactory;
     _eventManager         = eventManager;
     _router = router;
     _loggerFactoryBuilder = loggerFactoryBuilder;
     _settings             = settings;
 }
 public WebScriptHostManager(ScriptHostConfiguration config,
                             ISecretManagerFactory secretManagerFactory,
                             IScriptEventManager eventManager,
                             ScriptSettingsManager settingsManager,
                             WebHostSettings webHostSettings,
                             IWebJobsRouter router,
                             ILoggerFactoryBuilder loggerFactoryBuilder)
     : this(config, secretManagerFactory, eventManager, settingsManager, webHostSettings, router, new ScriptHostFactory(), loggerFactoryBuilder)
 {
 }
 public ScriptHostManager(
     ScriptHostConfiguration config,
     IScriptEventManager eventManager              = null,
     IScriptHostEnvironment environment            = null,
     ILoggerFactoryBuilder loggerFactoryBuilder    = null,
     HostPerformanceManager hostPerformanceManager = null)
     : this(config, ScriptSettingsManager.Instance, new ScriptHostFactory(), eventManager, environment, loggerFactoryBuilder, hostPerformanceManager)
 {
     if (config.FileWatchingEnabled)
     {
         // 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));
     }
 }
        public WebScriptHostManager(ScriptHostConfiguration config,
                                    ISecretManagerFactory secretManagerFactory,
                                    IScriptEventManager eventManager,
                                    ScriptSettingsManager settingsManager,
                                    WebHostSettings webHostSettings,
                                    IWebJobsRouter router,
                                    IScriptHostFactory scriptHostFactory = null,
                                    ISecretsRepositoryFactory secretsRepositoryFactory = null,
                                    ILoggerFactoryBuilder loggerFactoryBuilder         = null,
                                    HostPerformanceManager hostPerformanceManager      = null,
                                    int hostTimeoutSeconds = 30,
                                    int hostPollingIntervalMilliseconds = 500)
            : base(config, settingsManager, scriptHostFactory, eventManager, environment: null, loggerFactoryBuilder: loggerFactoryBuilder, hostPerformanceManager: hostPerformanceManager)
        {
            _config = config;

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

            var systemEventGenerator = config.HostConfig.GetService <IEventGenerator>() ?? new EventGenerator();
            var systemTraceWriter    = new SystemTraceWriter(systemEventGenerator, settingsManager, TraceLevel.Verbose);

            if (config.TraceWriter != null)
            {
                config.TraceWriter = new CompositeTraceWriter(new TraceWriter[] { config.TraceWriter, systemTraceWriter });
            }
            else
            {
                config.TraceWriter = systemTraceWriter;
            }

            config.IsSelfHost = webHostSettings.IsSelfHost;

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

            _secretManager = secretManagerFactory.Create(settingsManager, config.HostConfig.LoggerFactory, secretsRepository);

            _bindingWebHookProvider = new WebJobsSdkExtensionHookProvider(_secretManager);
        }
        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);
            }
        }
Exemplo n.º 7
0
            public ScriptHost Create(IScriptHostEnvironment environment, IScriptEventManager eventManager, ScriptSettingsManager settingsManager, ScriptHostConfiguration config, ILoggerFactoryBuilder loggerFactoryBuilder)
            {
                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(ScriptHost.Create(environment, eventManager, config, settingsManager, loggerFactoryBuilder));
            }