fix: preserve --host flag across update and restart (#972)
This commit is contained in:
@@ -1752,6 +1752,7 @@ function writeInstanceOptions(instanceFilePath, options, onNotice) {
|
|||||||
try {
|
try {
|
||||||
const toStore = {
|
const toStore = {
|
||||||
port: options.port,
|
port: options.port,
|
||||||
|
host: typeof options.host === 'string' && options.host.length > 0 ? options.host : undefined,
|
||||||
launchMode: options.launchMode === 'foreground' ? 'foreground' : 'daemon',
|
launchMode: options.launchMode === 'foreground' ? 'foreground' : 'daemon',
|
||||||
uiPassword: typeof options.uiPassword === 'string' ? options.uiPassword : undefined,
|
uiPassword: typeof options.uiPassword === 'string' ? options.uiPassword : undefined,
|
||||||
hasUiPassword: typeof options.uiPassword === 'string',
|
hasUiPassword: typeof options.uiPassword === 'string',
|
||||||
@@ -2931,6 +2932,7 @@ const commands = {
|
|||||||
writePidFile(fgPidFilePath, process.pid, emitNotice);
|
writePidFile(fgPidFilePath, process.pid, emitNotice);
|
||||||
writeInstanceOptions(fgInstanceFilePath, {
|
writeInstanceOptions(fgInstanceFilePath, {
|
||||||
port: resolvedPort,
|
port: resolvedPort,
|
||||||
|
host: effectiveHost,
|
||||||
launchMode: 'foreground',
|
launchMode: 'foreground',
|
||||||
uiPassword: effectiveUiPassword,
|
uiPassword: effectiveUiPassword,
|
||||||
}, emitNotice);
|
}, emitNotice);
|
||||||
@@ -3058,6 +3060,7 @@ const commands = {
|
|||||||
writePidFile(pidFilePath, child.pid, emitNotice);
|
writePidFile(pidFilePath, child.pid, emitNotice);
|
||||||
writeInstanceOptions(instanceFilePath, {
|
writeInstanceOptions(instanceFilePath, {
|
||||||
port: resolvedPort,
|
port: resolvedPort,
|
||||||
|
host: effectiveHost,
|
||||||
launchMode: 'daemon',
|
launchMode: 'daemon',
|
||||||
uiPassword: effectiveUiPassword,
|
uiPassword: effectiveUiPassword,
|
||||||
}, emitNotice);
|
}, emitNotice);
|
||||||
@@ -3356,6 +3359,7 @@ const commands = {
|
|||||||
|
|
||||||
const restartedPort = await this.serve({
|
const restartedPort = await this.serve({
|
||||||
port: restartPort,
|
port: restartPort,
|
||||||
|
host: storedOptions.host,
|
||||||
explicitPort: true,
|
explicitPort: true,
|
||||||
uiPassword: options.explicitUiPassword ? options.uiPassword : storedOptions.uiPassword,
|
uiPassword: options.explicitUiPassword ? options.uiPassword : storedOptions.uiPassword,
|
||||||
suppressStartupSummary: true,
|
suppressStartupSummary: true,
|
||||||
@@ -4791,6 +4795,7 @@ const commands = {
|
|||||||
const storedOptions = readInstanceOptions(instance.instanceFilePath) || { port: instance.port };
|
const storedOptions = readInstanceOptions(instance.instanceFilePath) || { port: instance.port };
|
||||||
await this.serve({
|
await this.serve({
|
||||||
port: storedOptions.port || instance.port,
|
port: storedOptions.port || instance.port,
|
||||||
|
host: storedOptions.host,
|
||||||
explicitPort: true,
|
explicitPort: true,
|
||||||
uiPassword: storedOptions.uiPassword,
|
uiPassword: storedOptions.uiPassword,
|
||||||
suppressStartupSummary: true,
|
suppressStartupSummary: true,
|
||||||
|
|||||||
@@ -130,6 +130,17 @@ export const registerOpenChamberRoutes = (app, dependencies) => {
|
|||||||
];
|
];
|
||||||
let restartCmdPrimary = restartParts.join(' ');
|
let restartCmdPrimary = restartParts.join(' ');
|
||||||
let restartCmdFallback = `openchamber serve --port ${storedOptions.port}`;
|
let restartCmdFallback = `openchamber serve --port ${storedOptions.port}`;
|
||||||
|
if (storedOptions.host) {
|
||||||
|
if (isWindows) {
|
||||||
|
const escapedHost = storedOptions.host.replace(/"/g, '""');
|
||||||
|
restartCmdPrimary += ` --host "${escapedHost}"`;
|
||||||
|
restartCmdFallback += ` --host "${escapedHost}"`;
|
||||||
|
} else {
|
||||||
|
const escapedHost = storedOptions.host.replace(/'/g, "'\\''");
|
||||||
|
restartCmdPrimary += ` --host '${escapedHost}'`;
|
||||||
|
restartCmdFallback += ` --host '${escapedHost}'`;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (storedOptions.uiPassword) {
|
if (storedOptions.uiPassword) {
|
||||||
if (isWindows) {
|
if (isWindows) {
|
||||||
const escapedPw = storedOptions.uiPassword.replace(/"/g, '""');
|
const escapedPw = storedOptions.uiPassword.replace(/"/g, '""');
|
||||||
|
|||||||
Reference in New Issue
Block a user