public async Task OnTimeoutExceptionAsync(ExceptionDispatchInfo exceptionInfo, TimeSpan timeoutGracePeriod) { FunctionTimeoutException timeoutException = exceptionInfo.SourceException as FunctionTimeoutException; if (timeoutException?.Task != null) { // We may double the timeoutGracePeriod here by first waiting to see if the iniital // function task that started the exception has completed. Task completedTask = await Task.WhenAny(timeoutException.Task, Task.Delay(timeoutGracePeriod)); // If the function task has completed, simply return. The host has already logged the timeout. if (completedTask == timeoutException.Task) { return; } } LogErrorAndFlush("A function timeout has occurred. Host is shutting down.", exceptionInfo.SourceException); // We can't wait on this as it may cause a deadlock if the timeout was fired // by a Listener that cannot stop until it has completed. Task ignoreTask = _manager.StopAsync(); // Give the manager and all running tasks some time to shut down gracefully. await Task.Delay(timeoutGracePeriod); HostingEnvironment.InitiateShutdown(); }
public override void Shutdown() { Instance?.TraceWriter.Info("Environment shutdown has been triggered. Stopping host and signaling shutdown."); Stop(); HostingEnvironment.InitiateShutdown(); }
/// <summary> /// Handles the Changed event of the fsw control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="FileSystemEventArgs"/> instance containing the event data.</param> public static void fsw_Changed(object sender, FileSystemEventArgs e) { FileInfo fileInfo = new FileInfo(e.FullPath); string[] extensionIgnoreFilter = new string[] { ".csv", ".ignore2", ".nupkg" }; string[] dirIgnoreFilter = new string[] { "Cache", "Logs", "App_Data" }; if (fileInfo.Attributes.HasFlag(FileAttributes.Directory)) { if (dirIgnoreFilter.Contains(fileInfo.Name)) { // directory content change and this is a directory to ignore return; } } if (dirIgnoreFilter.Contains(fileInfo.Directory.Name)) { // a file within an ignored folder changed return; } if (!extensionIgnoreFilter.Contains(fileInfo.Extension)) { if (!dirIgnoreFilter.Contains(fileInfo.Name)) { System.Diagnostics.Debug.WriteLine(string.Format("Initiate shutdown due to RockWeb file change: {0}", e.FullPath)); HostingEnvironment.InitiateShutdown(); } } }
/// <summary> /// Handles the Changed event of the fsw control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="FileSystemEventArgs"/> instance containing the event data.</param> public static void fsw_Changed(object sender, FileSystemEventArgs e) { FileInfo fileInfo = new FileInfo(e.FullPath); string[] extensionIgnoreFilter = new string[] { ".csv", ".ignore2" }; string[] dirIgnoreFilter = new string[] { "Cache", "Logs" }; if (fileInfo.Attributes.HasFlag(FileAttributes.Directory)) { if (dirIgnoreFilter.Contains(fileInfo.Name)) { // directory content change and this is a directory to ignore return; } } if (dirIgnoreFilter.Contains(fileInfo.Directory.Name)) { // a file within an ignored folder changed return; } if (!extensionIgnoreFilter.Contains(fileInfo.Extension)) { if (!dirIgnoreFilter.Contains(fileInfo.Name)) { HostingEnvironment.InitiateShutdown(); } } }
protected void btnShutdown_Click(object sender, EventArgs e) { if (IsValid()) { Logger.Warn("Shutdown requested"); HostingEnvironment.InitiateShutdown(); this.Response.Write("OK, Done."); } }
public override void Shutdown() { string message = "Environment shutdown has been triggered. Stopping host and signaling shutdown."; Instance?.TraceWriter.Info(message); Instance?.Logger?.LogInformation(message); Stop(); HostingEnvironment.InitiateShutdown(); }
public void TurnApplicationOnline() { Verify.IsFalse(this.IsApplicationOnline, "The application is already online"); Log.LogVerbose("ApplicationOnlineHandlerFacade", "Turning on the application"); if (_recompileCompositeGenerated) { try { CodeGenerationManager.GenerateCompositeGeneratedAssembly(); } catch (Exception ex) { Log.LogError(LogTitle, "Failed to recompile Composite.Generated.dll"); Log.LogError(LogTitle, ex); } } try { if (_wasLastTurnOffSoft == false) { ApplicationOnlineHandlerPluginFacade.TurnApplicationOnline(); Verify.IsTrue(ApplicationOnlineHandlerPluginFacade.IsApplicationOnline(), "Plugin failed to turn the application online"); } } finally { // Adding a sleep, so delayed notification from FileWatcher will not kill a newly spawned AppDomain Thread.Sleep(250); _shutdownGuard.Dispose(); _shutdownGuard = null; if (HostingEnvironment.IsHosted) { HostingEnvironment.InitiateShutdown(); } } _isApplicationOnline = true; }
//public static object App { get; private set; } public static void InitRecycleSync() { //Trace.WriteLine(DateTime.Now + " " + Process.GetCurrentProcess().Id + " Application_Start"); //System.Diagnostics.Trace.Flush(); try { newAppStartedGlobalEvent = new EventWaitHandle(false, EventResetMode.ManualReset, "clabs.cdeW3WPAppStarted", out bool createdNew); if (!createdNew) { // We found the event, so some other app instance is already running on this machine // Signal the event, so that the other app can shutdown newAppStartedGlobalEvent.Set(); newAppStartedGlobalEvent.Reset(); //Trace.WriteLine(DateTime.Now + " " + Process.GetCurrentProcess().Id + " Found previous app: signaling"); //System.Diagnostics.Trace.Flush(); } ThreadPool.RegisterWaitForSingleObject(newAppStartedGlobalEvent, (o, timedOut) => { //Trace.WriteLine(DateTime.Now + " " + Process.GetCurrentProcess().Id + " Signaled New App: Shutting Down"); //System.Diagnostics.Trace.Flush(); // Another app has started on this machine and signaled the event: let's shut down // Do our own shutdown first in case IIS terminates the process too aggressively ShutDown(); HostingEnvironment.InitiateShutdown(); // Event handle gets cleaned up for us by CLR/OS at process shutdown }, null, Timeout.Infinite, true); } catch (Exception) { //ingore } }
private void sendMessageCodeActivity_SendMessage_ExecuteCode(object sender, EventArgs e) { CloseCurrentView(); var timeZoneStandardName = GetBinding <string>("TimeZonesSelected"); var timezoneId = TimeZoneInfo.FindSystemTimeZoneById(timeZoneStandardName); var timezoneTransform = XDocument.Parse(String.Format(TimezoneXslt, timezoneId.Id)); ConfigurationServices.TransformConfiguration(timezoneTransform, false); HostingEnvironment.InitiateShutdown(); FlowControllerServicesContainer flowControllerServicesContainer = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId); IManagementConsoleMessageService managementConsoleMessageService = flowControllerServicesContainer.GetService <IManagementConsoleMessageService>(); managementConsoleMessageService.ShowGlobalMessage(DialogType.Message, StringResourceSystemFacade.GetString("Composite.Management", "SendMessageToConsolesWorkflow.SuccessMessage.TimezoneChangedTitle"), StringResourceSystemFacade.GetString("Composite.Management", "SendMessageToConsolesWorkflow.SuccessMessage.TimezoneChangedMessage")); managementConsoleMessageService.RebootConsole(); }
public void Shutdown() { HostingEnvironment.InitiateShutdown(); }
public Task OnUnhandledExceptionAsync(ExceptionDispatchInfo exceptionInfo) { LogErrorAndFlush("An unhandled exception has occurred. Host is shutting down.", exceptionInfo.SourceException); HostingEnvironment.InitiateShutdown(); return(Task.CompletedTask); }
/// <summary> /// Processes the command. /// </summary> /// <param name="msg">The MSG.</param> /// <returns></returns> bool ProcessCommand(Message msg) { string userAddress = string.Format(CultureInfo.InvariantCulture, "{0}@{1}", msg.From.User, msg.From.Server).ToLowerInvariant(); string command = msg.Body.ToLowerInvariant().Trim(); if (!command.StartsWith("/")) { return(false); } switch (command.Substring(1)) { case "subscribe": SubscriptionCollection.Instance.Add(userAddress); _Bot.Message(msg.From.ToString(), string.Format(CultureInfo.InvariantCulture, Texts.InfoSubscribeComplete, msg.From.User, msg.Body, BotVersion)); break; case "unsubscribe": SubscriptionCollection.Instance.Remove(userAddress); _Bot.Message(msg.From.ToString(), string.Format(CultureInfo.InvariantCulture, Texts.InfoUnsubscribeComplete, msg.From.User, msg.Body, BotVersion)); break; case "recycle": HostingEnvironment.InitiateShutdown(); break; case "subscribers": string list; if (SubscriptionCollection.Instance.Count > 0) { StringBuilder listDetail = new StringBuilder(); foreach (string user in SubscriptionCollection.Instance) { listDetail.AppendFormat("\r\n- {0}", user); } list = listDetail.ToString(); } else { list = Texts.NoSubscribers; } _Bot.Message(msg.From.ToString(), string.Format(CultureInfo.InvariantCulture, Texts.InfoSubscribers, list)); break; case "help": case "?": _Bot.Message(msg.From.ToString(), string.Format(CultureInfo.InvariantCulture, Texts.InfoHelpComplete, msg.From.User, msg.Body, BotVersion)); break; default: if (command.StartsWith("/announcement")) { SubscriptionCollection.Instance.Announcement = command.Substring(13).Trim(); _Bot.Presence(PresenceType.available, SubscriptionCollection.Instance.Announcement, null, 24); _Bot.Message(msg.From.ToString(), Texts.CommandComplete); } else { _Bot.Message(msg.From.ToString(), string.Format(CultureInfo.InvariantCulture, Texts.ErrorUnknownCommand, msg.From.User, msg.Body, BotVersion)); } break; } return(true); }
public void Uninstall(string packageId, string packageVersion) { _packageManager.UninstallPackage(packageId, new SemanticVersion(packageVersion)); HostingEnvironment.InitiateShutdown(); }
/// <summary> /// Handles the Changed event of the sourceFileFsw control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="FileSystemEventArgs"/> instance containing the event data.</param> static void sourceFileFsw_Changed(object sender, FileSystemEventArgs e) { HostingEnvironment.InitiateShutdown(); }
public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer) { HostingEnvironment.InitiateShutdown(); return(null); }
/// <summary> /// Handles the Changed event of the sourceFileFsw control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="FileSystemEventArgs"/> instance containing the event data.</param> static void sourceFileFsw_Changed(object sender, FileSystemEventArgs e) { // send debug info to debug window System.Diagnostics.Debug.WriteLine(string.Format("Initiate shutdown due to .cs source file change: {0}", e.FullPath)); HostingEnvironment.InitiateShutdown(); }