Skip to content

Commit

Permalink
feat(daemon): Always stop the daemon on purge (merge #2211)
Browse files Browse the repository at this point in the history
Ensures that the daemon is not restarted after being purged, even if it
was previously running. Any CLI command will simply restart the daemon
anyway.
  • Loading branch information
rekmarks authored Apr 15, 2024
2 parents 1f6c0b4 + c6a9b0c commit 443009d
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/cli/src/endo.js
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ export const main = async rawArgs => {
program
.command('purge')
.option('-f, --force', 'skip the confirmation prompt')
.description('erases persistent state and restarts if running')
.description('erases persistent state and stops if running')
.action(async cmd => {
const { force } = cmd.opts();
const doPurge =
Expand Down
11 changes: 1 addition & 10 deletions packages/daemon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,7 @@ export const restart = async (locator = defaultLocator) => {
};

export const purge = async (locator = defaultLocator) => {
// Attempt to restore to a running state if currently running, based on
// whether we manage to terminate it.
const needsRestart = await terminate(locator).then(
() => true,
() => false,
);
await terminate(locator).catch(() => {});

const cleanedUp = clean(locator);
const removedState = removePath(locator.statePath).catch(enoentOk);
Expand All @@ -179,8 +174,4 @@ export const purge = async (locator = defaultLocator) => {
removedEphemeralState,
removedCache,
]);

if (needsRestart) {
await start(locator);
}
};
1 change: 0 additions & 1 deletion packages/daemon/test/test-endo.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ const prepareLocator = async t => {
getLocatorDirectoryName(t.title, t.context.length),
);

await stop(locator).catch(() => {});
await purge(locator);
await start(locator);

Expand Down

0 comments on commit 443009d

Please sign in to comment.