private static void PullupBootstraps()
{
while (isRunning)
{
BootstrapsPullupResult result;
lock (Locker)
{
if (bootstraps == null)
{
bootstraps = new Bootstraps(options.ApplicationPath, options.ConfigPath, options.Threshold);
bootstraps.ApplicationFilesChanged += new EventHandler<FileSystemEventArgs>(BootstrapsApplicationFilesChanged);
bootstraps.Log += new EventHandler<EventLoggerEventArgs>(BootstrapsLog);
}
logger.Info("Starting the application at '{0}'.", bootstraps.ApplicationPath);
result = bootstraps.PullUp();
}
if (result.ResultType == BootstrapsPullupResultType.Success)
{
logger.Info("The application at '{0}' is running.", bootstraps.ApplicationPath);
break;
}
else
{
switch (result.ResultType)
{
case BootstrapsPullupResultType.ApplicationDirectoryNotFound:
logger.Warn("The application directory '{0}' was not found. Trying again in 10 seconds.", bootstraps.ApplicationPath);
break;
case BootstrapsPullupResultType.ConfigurationFileNotFound:
logger.Warn("The configuration file '{0}' was not found. Trying again in 10 seconds.", bootstraps.ConfigPath);
break;
case BootstrapsPullupResultType.Exception:
logger.Error(result.Exception, "An exception occurred while starting the application. Trying again in 10 seconds.");
break;
default:
throw new NotImplementedException();
}
Thread.Sleep(10000);
}
}
}