Kill processing on linux-.NET Core 1.1 service

I want to write a Linux service (for example, a Windows service), but I do not know how to safely stop this service.

I read about

AssemblyLoadContext.Default.Unloading += MethodInvokedOnSigTerm;

but it does not exist on .NET Core 1.1.

Do you have any ideas?

+4
source share
1 answer

If you can update the application to use .Net Core 1.2, this can be done using AppDomain.ProcessExitevent, but .Net Core 1.1this is not possible, according to this github problem .

, API Microsoft.NETCore.App 1.2.0-beta. , , CLI 4. API, .

System.Runtime.Loader.AssemblyLoadContext.Unloading .NET Core 1.0 System.Runtime.Loader, Version=4.0.0.0, PublicKeyToken=b03f5f7f11d50a3a. ? , .

using System.Runtime.Loader;

AssemblyLoadContext.Default.Unloading += MethodInvokedOnSigTerm;
0

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


All Articles