Skip to content

Commit 4a33a70

Browse files
committed
fix: streamline proxy server startup process by consolidating server initialization
1 parent 3c1f074 commit 4a33a70

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/core/ProxyServerSystem.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ class ProxyServerSystem extends EventEmitter {
5656

5757
async start(initialAuthIndex = null) {
5858
this.logger.info("[System] Starting flexible startup process...");
59+
await this._startHttpServer();
60+
await this._startWebSocketServer();
61+
this.logger.info(`[System] Proxy server system startup complete.`);
62+
5963
const allAvailableIndices = this.authSource.availableIndices;
6064

6165
if (allAvailableIndices.length === 0) {
@@ -86,13 +90,16 @@ class ProxyServerSystem extends EventEmitter {
8690
for (const index of startupOrder) {
8791
try {
8892
this.logger.info(`[System] Attempting to start service with account #${index}...`);
93+
this.requestHandler.authSwitcher.isSystemBusy = true;
8994
await this.browserManager.launchOrSwitchContext(index);
9095

9196
isStarted = true;
9297
this.logger.info(`[System] ✅ Successfully started with account #${index}!`);
9398
break;
9499
} catch (error) {
95100
this.logger.error(`[System] ❌ Failed to start with account #${index}. Reason: ${error.message}`);
101+
} finally {
102+
this.requestHandler.authSwitcher.isSystemBusy = false;
96103
}
97104
}
98105

@@ -103,9 +110,6 @@ class ProxyServerSystem extends EventEmitter {
103110
// Don't throw an error, just proceed to start servers
104111
}
105112

106-
await this._startHttpServer();
107-
await this._startWebSocketServer();
108-
this.logger.info(`[System] Proxy server system startup complete.`);
109113
this.emit("started");
110114
}
111115

0 commit comments

Comments
 (0)