Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: show some timing in dev admin startup #1620

Merged
merged 1 commit into from
Apr 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion packages/xarc-app-dev/lib/dev-admin/admin-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class AdminServer {
}

async start() {
this._startTime = Date.now();
this._io.show(ck`<orange>Dev Admin start time <cyan>${this._startTime}</></>`);
this._wds = ck`<gray.inverse>[wds]</> `;
this._proxy = ck`<green.inverse>[proxy]</> `;
this._app = ck`<cyan.inverse>[app]</> `;
Expand All @@ -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
Expand All @@ -94,6 +98,12 @@ class AdminServer {
}, 100);
}

logTime(msg) {
const now = Date.now();
const elapsed = (now - this._startTime) / 1000;
this._io.show(ck`<orange>${msg} was <cyan>${elapsed}</> seconds</>`);
}

updateStatus(line) {
if (line !== undefined) {
this._statusLine = line;
Expand Down Expand Up @@ -504,6 +514,7 @@ ${instruction}`
}

const str = data.toString();
context.checkLine && context.checkLine(str);
if (!str.trim()) {
store.push("");
logger.info("");
Expand All @@ -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,
Expand Down