Skip to content

Commit

Permalink
Generate uniq port
Browse files Browse the repository at this point in the history
  • Loading branch information
ziulev committed Dec 7, 2021
1 parent 01108a7 commit 24948a3
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/providers/plugins.provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -416,11 +416,20 @@ export const PluginsProvider: FC<{}> = (props) => {
await stopPluginScript(activePlugin.pid);
}

const port = randomPort();
const port = uniqPort();

return shell.execute(`nohup node ${pluginPath} ${port} ${pluginPath} > /dev/null 2>&1 &`);
}

const uniqPort = (): number => {
const port = randomPort();
const activePluginWithPort = activePlugins$.value.find(p =>
p.port === port,
);

return activePluginWithPort ? uniqPort() : port;
}

const stopPluginScript = async (
pid: number,
) => {
Expand Down

0 comments on commit 24948a3

Please sign in to comment.