Skip to content

Commit 1f5b408

Browse files
committed
Configuration initialization cleanup
1 parent 77ec255 commit 1f5b408

File tree

2 files changed

+7
-162
lines changed

2 files changed

+7
-162
lines changed

src/WebJobs.Script/Config/HostJsonFileConfigurationSource.cs

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -139,50 +139,12 @@ private JObject LoadHostConfigurationFile()
139139
string sanitizedJson = SanitizeHostJson(hostConfigObject);
140140
string readFileMessage = $"Host configuration file read:{NewLine}{sanitizedJson}";
141141

142-
// TODO: DI (FACAVAL) See method comments in ScriptHost
143-
//ApplyConfiguration(hostConfigObject, ScriptConfig, _startupLogger);
144-
145-
// TODO: DI (FACAVAL) Review - this should likely move and not be just config
146-
//if (_settingsManager.FileSystemIsReadOnly)
147-
//{
148-
// // we're in read-only mode so source files can't change
149-
// ScriptConfig.FileWatchingEnabled = false;
150-
//}
151-
152-
// now the configuration has been read and applied re-create the logger
153-
// factory and loggers ensuring that filters and settings have been applied
154-
// TODO: DI (FACAVAL) TODO
155-
//ConfigureLoggerFactory(recreate: true);
156-
157-
// TODO: DI (FACAVAL) Logger configuration to move to startup
158-
//_startupLogger = _hostOptions.LoggerFactory.CreateLogger(LogCategories.Startup);
159-
//Logger = _hostOptions.LoggerFactory.CreateLogger(ScriptConstants.LogCategoryHostGeneral);
160-
161-
// Allow tests to modify anything initialized by host.json
162-
//ScriptConfig.OnConfigurationApplied?.Invoke(ScriptConfig);
163142
_logger.LogTrace("Host configuration applied.");
164143

165144
// Do not log these until after all the configuration is done so the proper filters are applied.
166145
_logger.LogInformation(readingFileMessage);
167146
_logger.LogInformation(readFileMessage);
168147

169-
// TODO: DI (FACAVAL) Move to setup
170-
//if (string.IsNullOrEmpty(_hostOptions.HostId))
171-
//{
172-
// throw new InvalidOperationException("An 'id' must be specified in the host configuration.");
173-
//}
174-
175-
// TODO: DI (FACAVAL) Disabling core storage is now just a matter of
176-
// registering the appropriate services.
177-
//if (_storageConnectionString == null)
178-
//{
179-
// // Disable core storage
180-
// _hostOptions.StorageConnectionString = null;
181-
//}
182-
183-
// only after configuration has been applied and loggers
184-
// have been created, raise the initializing event
185-
186148
return hostConfigObject;
187149
}
188150

src/WebJobs.Script/Config/ScriptHostOptionsSetup.cs

Lines changed: 7 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ public void Configure(ScriptJobHostOptions options)
5656
// Worker configuration
5757
ConfigureLanguageWorkers(jobHostSection, options);
5858

59+
// If we have a read only file system, override any configuration and
60+
// disable file watching
61+
if (_environment.FileSystemIsReadOnly())
62+
{
63+
options.FileWatchingEnabled = false;
64+
}
65+
5966
// Set the root script path to the value the runtime was initialized with:
6067
ScriptApplicationHostOptions webHostOptions = _applicationHostOptions.Value;
6168
options.RootScriptPath = webHostOptions.ScriptPath;
@@ -135,129 +142,5 @@ private void ConfigureLanguageWorkers(IConfigurationSection rootConfig, ScriptJo
135142
}
136143
scriptOptions.MaxMessageLengthBytes = requestedGrpcMaxMessageLength;
137144
}
138-
139-
// TODO: DI (FACAVAL) Moved this from ScriptHost. Validate we're applying all configuration
140-
// Also noticed a lot of discrepancy between the original logic and the documentation and schema. We need to address
141-
// that. The current implemenation will match the original, which means that schema and docs will need to be udpated.
142-
//internal static void ApplyConfiguration(JObject config, ScriptHostConfiguration scriptConfig, ILogger logger = null)
143-
//{
144-
// var hostConfig = scriptConfig.HostOptions;
145-
146-
// hostConfig.HostConfigMetadata = config;
147-
148-
// JArray functions = (JArray)config["functions"];
149-
// if (functions != null && functions.Count > 0)
150-
// {
151-
// scriptConfig.Functions = new Collection<string>();
152-
// foreach (var function in functions)
153-
// {
154-
// scriptConfig.Functions.Add((string)function);
155-
// }
156-
// }
157-
// else
158-
// {
159-
// scriptConfig.Functions = null;
160-
// }
161-
162-
// // We may already have a host id, but the one from the JSON takes precedence
163-
// JToken hostId = (JToken)config["id"];
164-
// if (hostId != null)
165-
// {
166-
// hostConfig.HostId = (string)hostId;
167-
// }
168-
169-
// // Default AllowHostPartialStartup to true, but allow it
170-
// // to be overridden by config
171-
// hostConfig.AllowPartialHostStartup = true;
172-
// JToken allowPartialHostStartup = (JToken)config["allowPartialHostStartup"];
173-
// if (allowPartialHostStartup != null && allowPartialHostStartup.Type == JTokenType.Boolean)
174-
// {
175-
// hostConfig.AllowPartialHostStartup = (bool)allowPartialHostStartup;
176-
// }
177-
178-
// JToken fileWatchingEnabled = (JToken)config["fileWatchingEnabled"];
179-
// if (fileWatchingEnabled != null && fileWatchingEnabled.Type == JTokenType.Boolean)
180-
// {
181-
// scriptConfig.FileWatchingEnabled = (bool)fileWatchingEnabled;
182-
// }
183-
184-
// // Configure the set of watched directories, adding the standard built in
185-
// // set to any the user may have specified
186-
// if (scriptConfig.WatchDirectories == null)
187-
// {
188-
// scriptConfig.WatchDirectories = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
189-
// }
190-
// scriptConfig.WatchDirectories.Add("node_modules");
191-
// JToken watchDirectories = config["watchDirectories"];
192-
// if (watchDirectories != null && watchDirectories.Type == JTokenType.Array)
193-
// {
194-
// foreach (JToken directory in watchDirectories.Where(p => p.Type == JTokenType.String))
195-
// {
196-
// scriptConfig.WatchDirectories.Add((string)directory);
197-
// }
198-
// }
199-
200-
// JToken nugetFallbackFolder = config["nugetFallbackFolder"];
201-
// if (nugetFallbackFolder != null && nugetFallbackFolder.Type == JTokenType.String)
202-
// {
203-
// scriptConfig.NugetFallBackPath = (string)nugetFallbackFolder;
204-
// }
205-
206-
// // Apply Singleton configuration
207-
// JObject configSection = (JObject)config["singleton"];
208-
// JToken value = null;
209-
// if (configSection != null)
210-
// {
211-
// if (configSection.TryGetValue("lockPeriod", out value))
212-
// {
213-
// hostConfig.Singleton.LockPeriod = TimeSpan.Parse((string)value, CultureInfo.InvariantCulture);
214-
// }
215-
// if (configSection.TryGetValue("listenerLockPeriod", out value))
216-
// {
217-
// hostConfig.Singleton.ListenerLockPeriod = TimeSpan.Parse((string)value, CultureInfo.InvariantCulture);
218-
// }
219-
// if (configSection.TryGetValue("listenerLockRecoveryPollingInterval", out value))
220-
// {
221-
// hostConfig.Singleton.ListenerLockRecoveryPollingInterval = TimeSpan.Parse((string)value, CultureInfo.InvariantCulture);
222-
// }
223-
// if (configSection.TryGetValue("lockAcquisitionTimeout", out value))
224-
// {
225-
// hostConfig.Singleton.LockAcquisitionTimeout = TimeSpan.Parse((string)value, CultureInfo.InvariantCulture);
226-
// }
227-
// if (configSection.TryGetValue("lockAcquisitionPollingInterval", out value))
228-
// {
229-
// hostConfig.Singleton.LockAcquisitionPollingInterval = TimeSpan.Parse((string)value, CultureInfo.InvariantCulture);
230-
// }
231-
// }
232-
233-
// // Apply Host Health Montitor configuration
234-
// configSection = (JObject)config["healthMonitor"];
235-
// value = null;
236-
// if (configSection != null)
237-
// {
238-
// if (configSection.TryGetValue("enabled", out value) && value.Type == JTokenType.Boolean)
239-
// {
240-
// scriptConfig.HostHealthMonitor.Enabled = (bool)value;
241-
// }
242-
// if (configSection.TryGetValue("healthCheckInterval", out value))
243-
// {
244-
// scriptConfig.HostHealthMonitor.HealthCheckInterval = TimeSpan.Parse((string)value, CultureInfo.InvariantCulture);
245-
// }
246-
// if (configSection.TryGetValue("healthCheckWindow", out value))
247-
// {
248-
// scriptConfig.HostHealthMonitor.HealthCheckWindow = TimeSpan.Parse((string)value, CultureInfo.InvariantCulture);
249-
// }
250-
// if (configSection.TryGetValue("healthCheckThreshold", out value))
251-
// {
252-
// scriptConfig.HostHealthMonitor.HealthCheckThreshold = (int)value;
253-
// }
254-
// if (configSection.TryGetValue("counterThreshold", out value))
255-
// {
256-
// scriptConfig.HostHealthMonitor.CounterThreshold = (float)value;
257-
// }
258-
// }
259-
260-
// ApplyLanguageWorkersConfig(config, scriptConfig, logger);
261-
//}
262145
}
263146
}

0 commit comments

Comments
 (0)