Keep a self-service servicestack service open as a docker roaming service without using the console readline or readkey

I have a console application written in C # using a utility program that takes the following form:

static void Main(string[] args)
        {
            //Some service setup code here

            Console.ReadKey();
        }

This code works great when running on Windows as a console. The implementation is almost exactly https://github.com/ServiceStack/ServiceStack/wiki/Self-hosting as this is a test project

Then I will compile this project using mono on linux and creating a docker file.

I have no problem running a container based on this image if it is interactive

docker run -it --name bob -p 1337:1337 <myservice>

The container runs in the foreground

, -it, - , STDIN, Console.ReadKey() .

, , . , , ...

, (docker run -d...)

+4
1

.NET-, Console, , stdin Docker (docke run -i):

private ManualResetEvent Wait = new ManualResetEvent(false);
Wait.WaitOne();

Docker SIGTERM docker stop, ctrl-c SIGINT ,

Wait.Set();
+6

Source: https://habr.com/ru/post/1653118/


All Articles