Skip to content

Commit 00c6d48

Browse files
committed
feat: log timeout error
1 parent 834eadb commit 00c6d48

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/main/server/main.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class MainServer {
137137
/**
138138
* 确认服务是否可用
139139
*/
140-
private async checkServerIsReady() {
140+
private async checkServerIsReady(logError: boolean = false) {
141141
try {
142142
await new Promise((resolve, reject) => {
143143
const res = get(`http://localhost:${this.port}/api/v1/info`, (resp) => {
@@ -159,6 +159,7 @@ class MainServer {
159159
});
160160
}).on('error', (err) => {
161161
log.info('check server with resp err');
162+
logError && log.info(err);
162163
reject(err);
163164
});
164165
res.setTimeout(2000);
@@ -179,7 +180,7 @@ class MainServer {
179180
const getStatus = async (fn, reject) => {
180181
count++;
181182
log.info(`fetch server status count(${count})`);
182-
const isReady = await this.checkServerIsReady();
183+
const isReady = await this.checkServerIsReady(count > 70);
183184
if (isReady) {
184185
log.info(`Server startup time:`, (Date.now() - now) / 1000);
185186
fn(true);

0 commit comments

Comments
 (0)