Files
WireMock.Net/examples/WireMock.Net.StandAlone.NETCoreApp/Program.cs
Stef Heyenrath 141ed5d96c code update
2018-01-23 08:06:55 +01:00

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");
}
}
}