Recently I’ve noticed my ServiceStack docker containers are not shutting down when bad things happen like getting disconnected from RabbitMq.
When a fatal disconnect occurs I have my containers do Environment.Exit(1)
or if that fails they Environment.FailFast()
- this works fine for containers not hosting a servicestack instance. But the servicestack containers and process hangs around even after Exit.
I isolated a container and ran the dotnet MyServiceStackApp.dll
manually from inside and the logs look great:
---> (Inner Exception #0) RabbitMQ.Client.Exceptions.BrokerUnreachableException: None of the specified endpoints were reachable ---> RabbitMQ.Client.Exceptions.ConnectFailureException: Connection failed ---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException: No such device or address
at IPHostEntry System.Net.Dns.InternalGetHostByName(string hostName)
at void System.Net.Dns.ResolveCallback(object context)
at IPHostEntry System.Net.Dns.HostResolutionEndHelper(IAsyncResult asyncResult)
at IPAddress[] System.Net.Dns.EndGetHostAddresses(IAsyncResult asyncResult)
<-- snip -->
Application is shutting down...
but then I check the process list and see my app is still running
root@82eadfc3efa2:/app# ps -aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 18152 3236 pts/0 Ss 20:32 0:00 /bin/bash
root 8 0.4 1.9 22815560 154780 pts/0 SLl 20:32 0:02 dotnet MyServiceStackApp.dll
root 639 0.0 0.0 36640 2808 pts/0 R+ 20:42 0:00 ps -aux
What is the proper way to terminate a running servicestack web service?