Skip to content

Commit

Permalink
try to kill the process if somehow not detect server start whin defin…
Browse files Browse the repository at this point in the history
…ed period
  • Loading branch information
Blankll committed Jul 19, 2023
1 parent 252d17d commit 04bed77
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,13 @@ const start = async () => {
throw new Error('failed to start engine emit error');
});

await waitForLocalhost(engine, port);
try {
await waitForLocalhost(engine, port);
} catch (error) {
await killProcess();
throw error;
}

debug(`${engine} is running on port: ${port}, pid: ${server.pid}`);
await createIndexes();

Expand All @@ -106,8 +112,8 @@ const start = async () => {

const cleanupIndices = async (): Promise<void> => {
const { engine, port, indexes, zincAdmin, zincPassword } = engineOptions;
if (indexes.length <= 0) return;
debug(' deleting indexes');
if (indexes.length <= 0) return;
const result = execSync(
engine === EngineType.ZINCSEARCH
? `curl -s -X DELETE http://localhost:${port}/api/index/* -u ${zincAdmin}:${zincPassword}`
Expand Down

0 comments on commit 04bed77

Please sign in to comment.