Instead of the Node process exiting instantly on file change, send a signal to .NET that it should restart. This is working towards the connection-draining feature.

This commit is contained in:
SteveSandersonMS
2016-07-07 12:01:28 +01:00
parent a19e37f3c0
commit 26e8bd823c
4 changed files with 21 additions and 3 deletions

View File

@@ -18,6 +18,7 @@ namespace Microsoft.AspNetCore.NodeServices.HostingModels
public abstract class OutOfProcessNodeInstance : INodeInstance
{
private const string ConnectionEstablishedMessage = "[Microsoft.AspNetCore.NodeServices:Listening]";
private const string NeedsRestartMessage = "[Microsoft.AspNetCore.NodeServices:Restart]";
private readonly TaskCompletionSource<object> _connectionIsReadySource = new TaskCompletionSource<object>();
private bool _disposed;
private readonly StringAsTempFile _entryPointScript;
@@ -128,6 +129,13 @@ namespace Microsoft.AspNetCore.NodeServices.HostingModels
_connectionIsReadySource.SetResult(null);
initializationIsCompleted = true;
}
else if (evt.Data == NeedsRestartMessage)
{
// Temporarily, the file-watching logic is in Node, so look out for the
// signal that we need to restart. This can be removed once the file-watching
// logic is moved over to the .NET side.
Dispose();
}
else if (evt.Data != null)
{
OnOutputDataReceived(evt.Data);