mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-14 22:33:35 +01:00
42 lines
1.1 KiB
C#
42 lines
1.1 KiB
C#
using System;
|
|
using System.Threading;
|
|
using WireMock.Server;
|
|
|
|
namespace WireMock.Net.StandAlone.NETCoreApp
|
|
{
|
|
class Program
|
|
{
|
|
private static int sleepTime = 30000;
|
|
private static FluentMockServer _server;
|
|
|
|
static void Main(string[] args)
|
|
{
|
|
_server = StandAloneApp.Start(args);
|
|
|
|
Console.WriteLine($"{DateTime.UtcNow} Press Ctrl+C to shut down");
|
|
|
|
Console.CancelKeyPress += (s, e) =>
|
|
{
|
|
Stop("CancelKeyPress");
|
|
};
|
|
|
|
System.Runtime.Loader.AssemblyLoadContext.Default.Unloading += ctx =>
|
|
{
|
|
Stop("AssemblyLoadContext.Default.Unloading");
|
|
};
|
|
|
|
while (true)
|
|
{
|
|
Console.WriteLine($"{DateTime.UtcNow} WireMock.Net server running");
|
|
Thread.Sleep(sleepTime);
|
|
}
|
|
}
|
|
|
|
private static void Stop(string why)
|
|
{
|
|
Console.WriteLine($"{DateTime.UtcNow} WireMock.Net server stopping because '{why}'");
|
|
_server.Stop();
|
|
Console.WriteLine($"{DateTime.UtcNow} WireMock.Net server stopped");
|
|
}
|
|
}
|
|
} |