mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-23 10:08:57 +00:00
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:
@@ -184,7 +184,10 @@
|
|||||||
var ext = path.extname(filename);
|
var ext = path.extname(filename);
|
||||||
if (extensions.indexOf(ext) >= 0) {
|
if (extensions.indexOf(ext) >= 0) {
|
||||||
console.log('Restarting due to file change: ' + filename);
|
console.log('Restarting due to file change: ' + filename);
|
||||||
process.exit(0);
|
// Temporarily, the file-watching logic is in Node, so we signal it's time to restart by
|
||||||
|
// sending the following message back to .NET. Soon the file-watching logic will move over
|
||||||
|
// to the .NET side, and this whole file can be removed.
|
||||||
|
console.log('[Microsoft.AspNetCore.NodeServices:Restart]');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,7 +95,10 @@
|
|||||||
var ext = path.extname(filename);
|
var ext = path.extname(filename);
|
||||||
if (extensions.indexOf(ext) >= 0) {
|
if (extensions.indexOf(ext) >= 0) {
|
||||||
console.log('Restarting due to file change: ' + filename);
|
console.log('Restarting due to file change: ' + filename);
|
||||||
process.exit(0);
|
// Temporarily, the file-watching logic is in Node, so we signal it's time to restart by
|
||||||
|
// sending the following message back to .NET. Soon the file-watching logic will move over
|
||||||
|
// to the .NET side, and this whole file can be removed.
|
||||||
|
console.log('[Microsoft.AspNetCore.NodeServices:Restart]');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ namespace Microsoft.AspNetCore.NodeServices.HostingModels
|
|||||||
public abstract class OutOfProcessNodeInstance : INodeInstance
|
public abstract class OutOfProcessNodeInstance : INodeInstance
|
||||||
{
|
{
|
||||||
private const string ConnectionEstablishedMessage = "[Microsoft.AspNetCore.NodeServices:Listening]";
|
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 readonly TaskCompletionSource<object> _connectionIsReadySource = new TaskCompletionSource<object>();
|
||||||
private bool _disposed;
|
private bool _disposed;
|
||||||
private readonly StringAsTempFile _entryPointScript;
|
private readonly StringAsTempFile _entryPointScript;
|
||||||
@@ -128,6 +129,13 @@ namespace Microsoft.AspNetCore.NodeServices.HostingModels
|
|||||||
_connectionIsReadySource.SetResult(null);
|
_connectionIsReadySource.SetResult(null);
|
||||||
initializationIsCompleted = true;
|
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)
|
else if (evt.Data != null)
|
||||||
{
|
{
|
||||||
OnOutputDataReceived(evt.Data);
|
OnOutputDataReceived(evt.Data);
|
||||||
|
|||||||
@@ -8,7 +8,11 @@ export function autoQuitOnFileChange(rootDir: string, extensions: string[]) {
|
|||||||
var ext = path.extname(filename);
|
var ext = path.extname(filename);
|
||||||
if (extensions.indexOf(ext) >= 0) {
|
if (extensions.indexOf(ext) >= 0) {
|
||||||
console.log('Restarting due to file change: ' + filename);
|
console.log('Restarting due to file change: ' + filename);
|
||||||
process.exit(0);
|
|
||||||
|
// Temporarily, the file-watching logic is in Node, so we signal it's time to restart by
|
||||||
|
// sending the following message back to .NET. Soon the file-watching logic will move over
|
||||||
|
// to the .NET side, and this whole file can be removed.
|
||||||
|
console.log('[Microsoft.AspNetCore.NodeServices:Restart]');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user