in src/WebJobs.Extensions/Extensions/Timers/Scheduling/FileSystemScheduleMonitor.cs [32:73]
public FileSystemScheduleMonitor(string currentDirectory)
{
if (string.IsNullOrEmpty(currentDirectory))
{
throw new ArgumentNullException("currentDirectory");
}
// default to the D:\HOME\DATA directory when running in Azure WebApps
string home = Environment.GetEnvironmentVariable("HOME");
string rootPath = string.Empty;
if (!string.IsNullOrEmpty(home))
{
rootPath = Path.Combine(home, "data");
// Determine the path to the WebJobs folder, so we can write our status
// files there. We leverage the fact that the TEMP directory structure we
// run from is the same as the data directory structure
int start = currentDirectory.IndexOf("jobs", StringComparison.OrdinalIgnoreCase);
int end = currentDirectory.LastIndexOf(Path.DirectorySeparatorChar);
if (start > 0 && end > 0)
{
string jobPath = currentDirectory.Substring(start, end - start);
_statusFilePath = Path.Combine(rootPath, jobPath);
}
}
else
{
rootPath = Path.GetTempPath();
}
if (string.IsNullOrEmpty(_statusFilePath) || !Directory.Exists(_statusFilePath))
{
_statusFilePath = Path.Combine(rootPath, @"webjobs\timers");
}
Directory.CreateDirectory(_statusFilePath);
JsonSerializerSettings settings = new JsonSerializerSettings
{
DateFormatHandling = DateFormatHandling.IsoDateFormat
};
_serializer = JsonSerializer.Create(settings);
}