mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
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:
@@ -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"
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user