-
Notifications
You must be signed in to change notification settings - Fork 524
UNIX sockets not cleaned up on exit #419
Comments
As a guess, |
Supervisor sends |
@CesarBS - unfortunately it looks like that didn't work. This is my full config:
Here's what I was doing:
SIGTERM should still clean up the sockets, right? I didn't know much about the different signals, but I found this useful post on Quora that explains them. Emphasis mine:
|
My suggestion was actually an educated guess. I didn't really run Kestrel behind Supervisor - what I actually did was to check the behavior difference between killing kestrel with SIGTERM and SIGINT and I noticed that the socket lingered around with SIGTERM but not with SIGINT. Just to make sure: did you restart Supervisor after setting |
Yeah, I restarted Supervisor. |
When I try running an app with supervisor, I get
Have you ever run into that? |
Try checking the output. |
Can your app run on CoreCLR? I'm now able to repro your issue, but I noticed it only happens on Mono. If I use the CoreCLR DNX the socket is gone once Supervisor stops the process. |
Unfortunately I can't use CoreCLR yet as I'm using some third-party libraries that don't support it and also some stuff in the |
Can you run your app manually, kill it with |
Interesting... It does appear to correctly clean up the socket when I run the app manually and use |
It's what I'm trying to figure out. So far I haven't found anything weird in their code. I suspected Python's os.kill could be doing something funny but I tested it and the socket is cleaned. I'll keep investigating. |
@Daniel15 After a little more investigation, this continues to be a mystery. It looks very much like a Mono issue. Can you open an issue on Mono for this? Meanwhile I suggest you work around this issue by setting your Supervisor command to a script that first deletes the socket file and then launches your app. @muratg Since this looks like a Mono issue, I'll go ahead and close this. |
I tried to repro this outside of Supervisor
|
This is a known issue that we had with DNX and will continue to have with dotnet. It's not really up to Kestrel to do it, but in any case we're unable to handle |
Now that ASP.NET Core websites are just .NET executables, it was easy enough to modify my public static void Main(string[] args)
{
var config = new ConfigurationBuilder()
.AddCommandLine(args)
.Build();
var host = new WebHostBuilder()
.UseKestrel()
.UseConfiguration(config)
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
// Delete UNIX pipe if it exists at startup (eg. previous process crashed before cleaning it up)
var addressFeature = host.ServerFeatures.Get<IServerAddressesFeature>();
var url = ServerAddress.FromUrl(addressFeature.Addresses.First());
if (url.IsUnixPipe && File.Exists(url.UnixPipePath))
{
Console.WriteLine("UNIX pipe {0} already existed, deleting it.", url.UnixPipePath);
File.Delete(url.UnixPipePath);
}
host.Run();
} |
I'm using Supervisord to run Kestrel for my site. This is my Supervisor config:
Command in
project.json
:This is working fine, but when I stop Kestrel (
supervisorctl stop dan
, "dan" being the name of the site in the Supervisor config), it does not clean up the UNIX socket (/run/dan-live.sock
). The next time I try to start it, I get an "address already in use" error:I need to manually
rm /run/dan-live.sock
before I can start Kestrel again. I think Kestrel simply needs to delete the socket on exit.The text was updated successfully, but these errors were encountered: