Skip to content

Commit

Permalink
🐛 Wait for healthcheck to fail for exec:stop
Browse files Browse the repository at this point in the history
  • Loading branch information
wwilsman committed Sep 30, 2020
1 parent d95d557 commit d756fde
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/cli-exec/src/commands/exec/stop.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,27 @@ export class Stop extends Command {
};

async run() {
let { port } = this.flags;

if (!this.isPercyEnabled()) {
log.info('Percy is disabled');
return;
}

try {
let { port } = this.flags;
await request(`http://localhost:${port}/percy/stop`, { method: 'POST' });
log.info('Percy has stopped');
} catch (err) {
log.error('Percy is not running');
log.debug(err);
this.exit(1);
}

// retry heathcheck until it fails
await new Promise(function check(resolve) {
return request(`http://localhost:${port}/percy/healthcheck`, { method: 'GET' })
.then(() => setTimeout(check, 100, resolve)).catch(resolve);
});

log.info('Percy has stopped');
}
}

0 comments on commit d756fde

Please sign in to comment.