/// <summary> /// Listen <see cref="AppDomain.CurrentDomain.ProcessExit"/> and shutdown vostok if SIGTERM received. /// </summary> public static VostokHost WithSigtermCancellation([NotNull] this VostokHost vostokHost) { AppDomain.CurrentDomain.ProcessExit += (sender, e) => { vostokHost.Stop(); }; return(vostokHost); }
/// <summary> /// Listen <see cref="Console.CancelKeyPress"/> and shutdown vostok host if called. /// </summary> public static VostokHost WithConsoleCancellation([NotNull] this VostokHost vostokHost) { Console.CancelKeyPress += (sender, e) => { e.Cancel = true; vostokHost.ShutdownTokenSource.Cancel(); }; return(vostokHost); }
/// <inheritdoc cref="VostokHost.RunAsync"/> public static VostokApplicationRunResult Run([NotNull] this VostokHost vostokHost) => vostokHost.RunAsync().GetAwaiter().GetResult();
public static VostokApplicationRunResult Stop([NotNull] this VostokHost vostokHost, bool ensureSuccess) => vostokHost.StopAsync(ensureSuccess).GetAwaiter().GetResult();
/// <inheritdoc cref="VostokHost.StartAsync"/> public static void Start([NotNull] this VostokHost vostokHost, VostokApplicationState stateToAwait) => vostokHost.StartAsync(stateToAwait).GetAwaiter().GetResult();
/// <inheritdoc cref="VostokHost.StartAsync"/> public static void Start([NotNull] this VostokHost vostokHost) => vostokHost.StartAsync().GetAwaiter().GetResult();