Esempio n. 1
0
        /// <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);
        }
Esempio n. 2
0
        /// <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);
        }
Esempio n. 3
0
 /// <inheritdoc cref="VostokHost.RunAsync"/>
 public static VostokApplicationRunResult Run([NotNull] this VostokHost vostokHost) =>
 vostokHost.RunAsync().GetAwaiter().GetResult();
Esempio n. 4
0
 public static VostokApplicationRunResult Stop([NotNull] this VostokHost vostokHost, bool ensureSuccess) =>
 vostokHost.StopAsync(ensureSuccess).GetAwaiter().GetResult();
Esempio n. 5
0
 /// <inheritdoc cref="VostokHost.StartAsync"/>
 public static void Start([NotNull] this VostokHost vostokHost, VostokApplicationState stateToAwait) =>
 vostokHost.StartAsync(stateToAwait).GetAwaiter().GetResult();
Esempio n. 6
0
 /// <inheritdoc cref="VostokHost.StartAsync"/>
 public static void Start([NotNull] this VostokHost vostokHost) =>
 vostokHost.StartAsync().GetAwaiter().GetResult();