Use IPC message to handle .reload command in meteor shell.

I considered using a nonzero process.exit code, but I didn't want to run
any risk of reusing a meaningful code, and the accepted range of codes
unfortunately does not include parseInt("reload", 36), or 1657112629.

Should fix #10934.
This commit is contained in:
Ben Newman
2020-02-26 11:21:40 -05:00
parent 6232550cb8
commit a467255d9c
3 changed files with 17 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
Package.describe({
name: "shell-server",
version: "0.4.0",
version: "0.5.0",
summary: "Server-side component of the `meteor shell` command.",
documentation: "README.md"
});

View File

@@ -12,6 +12,9 @@ import {
import { createServer } from "net";
import { start as replStart } from "repl";
// Enable process.sendMessage for communication with build process.
import "meteor/inter-process-messaging";
const INFO_FILE_MODE = parseInt("600", 8); // Only the owner can read or write.
const EXITING_MESSAGE = "Shell exiting...";
@@ -308,7 +311,11 @@ class Server {
repl.defineCommand("reload", {
help: "Restart the server and the shell",
action: function() {
process.exit(0);
if (process.sendMessage) {
process.sendMessage("shell-server", { command: "reload" });
} else {
process.exit(0);
}
}
});
}

View File

@@ -767,6 +767,14 @@ _.extend(AppRunner.prototype, {
var serverWatcher;
var clientWatcher;
appProcess.proc.onMessage("shell-server", message => {
if (message && message.command === "reload") {
self._resolvePromise("run", { outcome: "changed" });
} else {
return Promise.reject("Unsupported shell command: " + message);
}
});
if (self.watchForChanges) {
serverWatcher = new watch.Watcher({
watchSet: serverWatchSet,