From e5dbfb22ac54f5f9cacae94d89c9f36005352557 Mon Sep 17 00:00:00 2001 From: Joel Chen Date: Thu, 23 Apr 2020 19:23:27 -0700 Subject: [PATCH] fix: show some timing in dev admin startup --- .../lib/dev-admin/admin-server.js | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/packages/xarc-app-dev/lib/dev-admin/admin-server.js b/packages/xarc-app-dev/lib/dev-admin/admin-server.js index 778cd3d2d..5e0e52b0b 100644 --- a/packages/xarc-app-dev/lib/dev-admin/admin-server.js +++ b/packages/xarc-app-dev/lib/dev-admin/admin-server.js @@ -65,6 +65,8 @@ class AdminServer { } async start() { + this._startTime = Date.now(); + this._io.show(ck`Dev Admin start time ${this._startTime}`); this._wds = ck`[wds] `; this._proxy = ck`[proxy] `; this._app = ck`[app] `; @@ -80,7 +82,9 @@ class AdminServer { this.updateStatus("webpack is PENDING"); this.handleUserInput(); + this._fullyStarted = false; this._shutdown || (await this.startWebpackDevServer()); + this.logTime(`Time Webpack Dev Server took`); this._shutdown || (await this.startAppServer()); if (!this._shutdown && DEV_PROXY_ENABLED) { // to debug dev proxy @@ -94,6 +98,12 @@ class AdminServer { }, 100); } + logTime(msg) { + const now = Date.now(); + const elapsed = (now - this._startTime) / 1000; + this._io.show(ck`${msg} was ${elapsed} seconds`); + } + updateStatus(line) { if (line !== undefined) { this._statusLine = line; @@ -504,6 +514,7 @@ ${instruction}` } const str = data.toString(); + context.checkLine && context.checkLine(str); if (!str.trim()) { store.push(""); logger.info(""); @@ -527,7 +538,18 @@ ${instruction}` async startAppServer(debug) { const skipWatch = debug === "--inspect-brk"; - const logSaver = { tag: this._app, store: [], fullLogUrl: this._fullAppLogUrl }; + const logSaver = { + tag: this._app, + store: [], + fullLogUrl: this._fullAppLogUrl, + checkLine: str => { + if (!this._fullyStarted && str.includes("server running")) { + this._fullyStarted = true; + this.logTime(`App is ready in dev mode, total time took`); + } + return str; + } + }; await this.startServer({ name: APP_SERVER_NAME,