mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 11:28:38 +00:00
fix(update): restart daemon after service refresh
This commit is contained in:
@@ -482,6 +482,7 @@ describe("update-cli", () => {
|
|||||||
force: true,
|
force: true,
|
||||||
json: undefined,
|
json: undefined,
|
||||||
});
|
});
|
||||||
|
expect(runRestartScript).toHaveBeenCalled();
|
||||||
expect(runDaemonRestart).not.toHaveBeenCalled();
|
expect(runDaemonRestart).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -508,6 +509,29 @@ describe("update-cli", () => {
|
|||||||
expect(runDaemonRestart).toHaveBeenCalled();
|
expect(runDaemonRestart).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("updateCommand falls back to restart when no detached restart script is available", async () => {
|
||||||
|
const mockResult: UpdateRunResult = {
|
||||||
|
status: "ok",
|
||||||
|
mode: "git",
|
||||||
|
steps: [],
|
||||||
|
durationMs: 100,
|
||||||
|
};
|
||||||
|
|
||||||
|
vi.mocked(runGatewayUpdate).mockResolvedValue(mockResult);
|
||||||
|
vi.mocked(runDaemonInstall).mockResolvedValue(undefined);
|
||||||
|
prepareRestartScript.mockResolvedValue(null);
|
||||||
|
serviceLoaded.mockResolvedValue(true);
|
||||||
|
vi.mocked(runDaemonRestart).mockResolvedValue(true);
|
||||||
|
|
||||||
|
await updateCommand({});
|
||||||
|
|
||||||
|
expect(runDaemonInstall).toHaveBeenCalledWith({
|
||||||
|
force: true,
|
||||||
|
json: undefined,
|
||||||
|
});
|
||||||
|
expect(runDaemonRestart).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
it("updateCommand does not refresh service env when --no-restart is set", async () => {
|
it("updateCommand does not refresh service env when --no-restart is set", async () => {
|
||||||
vi.mocked(runGatewayUpdate).mockResolvedValue(makeOkUpdateResult());
|
vi.mocked(runGatewayUpdate).mockResolvedValue(makeOkUpdateResult());
|
||||||
serviceLoaded.mockResolvedValue(true);
|
serviceLoaded.mockResolvedValue(true);
|
||||||
|
|||||||
@@ -403,12 +403,9 @@ async function maybeRestartService(params: {
|
|||||||
try {
|
try {
|
||||||
let restarted = false;
|
let restarted = false;
|
||||||
let restartInitiated = false;
|
let restartInitiated = false;
|
||||||
let serviceRefreshed = false;
|
|
||||||
if (params.refreshServiceEnv) {
|
if (params.refreshServiceEnv) {
|
||||||
try {
|
try {
|
||||||
await runDaemonInstall({ force: true, json: params.opts.json });
|
await runDaemonInstall({ force: true, json: params.opts.json });
|
||||||
serviceRefreshed = true;
|
|
||||||
restarted = true;
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (!params.opts.json) {
|
if (!params.opts.json) {
|
||||||
defaultRuntime.log(
|
defaultRuntime.log(
|
||||||
@@ -419,13 +416,11 @@ async function maybeRestartService(params: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!serviceRefreshed && params.restartScriptPath) {
|
if (params.restartScriptPath) {
|
||||||
await runRestartScript(params.restartScriptPath);
|
await runRestartScript(params.restartScriptPath);
|
||||||
restartInitiated = true;
|
restartInitiated = true;
|
||||||
} else {
|
} else {
|
||||||
if (!serviceRefreshed) {
|
restarted = await runDaemonRestart();
|
||||||
restarted = await runDaemonRestart();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!params.opts.json && restarted) {
|
if (!params.opts.json && restarted) {
|
||||||
|
|||||||
Reference in New Issue
Block a user