























@@ -816,6 +816,52 @@ describe("systemd service install and uninstall", () => {
816816});
817817});
818818819+it("retries enable after reloading again when systemd cannot see the written unit yet", async () => {
820+await withNodeSystemdFixture(async ({ env }) => {
821+execFileMock
822+.mockImplementationOnce((_cmd, args, _opts, cb) => {
823+assertUserSystemctlArgs(args, "status");
824+cb(null, "", "");
825+})
826+.mockImplementationOnce((_cmd, args, _opts, cb) => {
827+assertUserSystemctlArgs(args, "daemon-reload");
828+cb(null, "", "");
829+})
830+.mockImplementationOnce((_cmd, args, _opts, cb) => {
831+assertUserSystemctlArgs(args, "enable", NODE_SERVICE);
832+cb(
833+createExecFileError("enable failed"),
834+"",
835+"Unit file openclaw-node.service does not exist.",
836+);
837+})
838+.mockImplementationOnce((_cmd, args, _opts, cb) => {
839+assertUserSystemctlArgs(args, "daemon-reload");
840+cb(null, "", "");
841+})
842+.mockImplementationOnce((_cmd, args, _opts, cb) => {
843+assertUserSystemctlArgs(args, "enable", NODE_SERVICE);
844+cb(null, "", "");
845+})
846+.mockImplementationOnce((_cmd, args, _opts, cb) => {
847+assertUserSystemctlArgs(args, "restart", NODE_SERVICE);
848+cb(null, "", "");
849+});
850+851+await installSystemdService({
852+ env,
853+stdout: { write: vi.fn() } as unknown as NodeJS.WritableStream,
854+programArguments: ["/usr/bin/openclaw", "node", "run"],
855+workingDirectory: "/tmp",
856+environment: {
857+OPENCLAW_SYSTEMD_UNIT: "openclaw-node",
858+},
859+});
860+861+expect(execFileMock).toHaveBeenCalledTimes(6);
862+});
863+});
864+819865it("disables the OPENCLAW_SYSTEMD_UNIT override during uninstall", async () => {
820866await withNodeSystemdFixture(async ({ env, unitPath }) => {
821867await fs.mkdir(path.dirname(unitPath), { recursive: true });
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。