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