mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-11-10 04:46:07 -08:00
fix(stats): harden server lifecycle and verify compiled runtime (#261)
This commit is contained in:
1 parent
f9c4e892dc
commit
383aed8bad
37 files changed
+1381
-323
No files matched your search
@@ -6,7 +6,7 @@ type EnsureStatsServerUrlDeps = {
|
||||
removeBackgroundState: () => void;
|
||||
isProcessAlive: (pid: number) => boolean;
|
||||
hasLocalStatsServer: () => boolean;
|
||||
startLocalStatsServer: () => void;
|
||||
startLocalStatsServer: () => Promise<void>;
|
||||
getConfiguredPort: () => number;
|
||||
};
|
||||
|
||||
@@ -18,8 +18,8 @@ export type EnsureStatsServerUrlResult = { url: string; source: 'background' | '
|
||||
|
||||
export function createEnsureStatsServerUrlHandler(
|
||||
deps: EnsureStatsServerUrlDeps,
|
||||
): () => EnsureStatsServerUrlResult {
|
||||
return () => {
|
||||
): () => Promise<EnsureStatsServerUrlResult> {
|
||||
return async () => {
|
||||
const state = deps.readBackgroundState();
|
||||
if (!state) {
|
||||
deps.removeBackgroundState();
|
||||
@@ -32,7 +32,7 @@ export function createEnsureStatsServerUrlHandler(
|
||||
}
|
||||
|
||||
if (!deps.hasLocalStatsServer()) {
|
||||
deps.startLocalStatsServer();
|
||||
await deps.startLocalStatsServer();
|
||||
}
|
||||
return { url: formatStatsServerUrl(deps.getConfiguredPort()), source: 'local' };
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user