コード例 #1
0
        public void Configure(HttpWorkerOptions options)
        {
            IConfigurationSection jobHostSection = _configuration.GetSection(ConfigurationSectionNames.JobHost);
            var httpWorkerSection = jobHostSection.GetSection(ConfigurationSectionNames.HttpWorker);

            if (httpWorkerSection.Exists())
            {
                httpWorkerSection.Bind(options);
                HttpWorkerDescription httpWorkerDescription = options.Description;

                if (httpWorkerDescription == null)
                {
                    throw new HostConfigurationException($"Missing WorkerDescription for HttpWorker");
                }
                httpWorkerDescription.ApplyDefaultsAndValidate(_scriptJobHostOptions.RootScriptPath, _logger);
                options.Arguments = new WorkerProcessArguments()
                {
                    ExecutablePath = options.Description.DefaultExecutablePath,
                    WorkerPath     = options.Description.DefaultWorkerPath
                };

                options.Arguments.ExecutableArguments.AddRange(options.Description.Arguments);
                options.Port = GetUnusedTcpPort();
                _logger.LogDebug("Configured httpWorker with {DefaultExecutablePath}: {exepath} with arguments {args}", nameof(options.Description.DefaultExecutablePath), options.Description.DefaultExecutablePath, options.Arguments);
            }
        }
コード例 #2
0
        private void ConfigureWorkerDescription(HttpWorkerOptions options, IConfigurationSection workerSection)
        {
            workerSection.Bind(options);
            HttpWorkerDescription httpWorkerDescription = options.Description;

            if (httpWorkerDescription == null)
            {
                throw new HostConfigurationException($"Missing worker Description.");
            }

            var argumentsList = GetArgumentList(workerSection, argumentsSectionName);

            if (argumentsList != null)
            {
                httpWorkerDescription.Arguments = argumentsList;
            }

            var workerArgumentList = GetArgumentList(workerSection, workerArgumentsSectionName);

            if (workerArgumentList != null)
            {
                httpWorkerDescription.WorkerArguments = workerArgumentList;
            }

            httpWorkerDescription.ApplyDefaultsAndValidate(_scriptJobHostOptions.RootScriptPath, _logger);

            // Set default working directory to function app root.
            if (string.IsNullOrEmpty(httpWorkerDescription.WorkingDirectory))
            {
                httpWorkerDescription.WorkingDirectory = _scriptJobHostOptions.RootScriptPath;
            }
            else
            {
                // Compute working directory relative to fucntion app root.
                if (!Path.IsPathRooted(httpWorkerDescription.WorkingDirectory))
                {
                    httpWorkerDescription.WorkingDirectory = Path.Combine(_scriptJobHostOptions.RootScriptPath, httpWorkerDescription.WorkingDirectory);
                }
            }

            options.Arguments = new WorkerProcessArguments()
            {
                ExecutablePath = options.Description.DefaultExecutablePath,
                WorkerPath     = options.Description.DefaultWorkerPath
            };

            options.Arguments.ExecutableArguments.AddRange(options.Description.Arguments);
            options.Arguments.WorkerArguments.AddRange(options.Description.WorkerArguments);
            options.Port = WorkerUtilities.GetUnusedTcpPort();
        }