mirror of
https://github.com/discourse/discourse.git
synced 2024-12-30 08:53:54 +08:00
9db5eafb15
- Use 'cheap-source-map' webpack config on low-memory machines This results in worse quality sourcemaps in browser dev tools, but it significantly reduces memory use in our webpack build. In approximate local testing it drops from 1100mb to 590mb. This should make the rebuild process on low-memory machines much faster and less likely to trigger OOM errors. In development, and on higher-memory machines, the higher-quality 'source-map' option is maintained. - Disable Webpack's built-in `minimize` feature. Embroider already applies Terser after the webpack build is complete. There is no need to double-minimize the output. - Update ember-cli-progress-ci to print to stderr instead of stdout. For some reason, pups (used by discourse_docker) buffers the stdout of commands and only prints when they are finished. stderr does not have this same limitation, so switching will mean sysadmins can see the progress of the ember build in real-time. Given the number of variables it's hard to promise exact numbers. But, in my tests on a DO droplet with 1GB RAM (+2GB swap), this reduced the `ember build` portion of a `./launcher rebuild app` from ~50 minutes to ~15 minutes.
55 lines
1.2 KiB
JavaScript
55 lines
1.2 KiB
JavaScript
"use strict";
|
|
|
|
const progress = require("ember-cli/lib/utilities/heimdall-progress");
|
|
|
|
const CHECK_INTERVAL = 100;
|
|
const LOG_DUPLICATE_AFTER_DURATION = 5000;
|
|
|
|
const REPEAT_DUPLICATE_LOG_ITERATIONS =
|
|
LOG_DUPLICATE_AFTER_DURATION / CHECK_INTERVAL;
|
|
|
|
// If running in CI mode, this addon will poll the current build node and log it.
|
|
// If the node runs for more than LOG_DUPLICATE_AFTER_DURATION, it will be logged again.
|
|
module.exports = {
|
|
name: require("./package").name,
|
|
|
|
preBuild() {
|
|
if (this.project.ui.ci) {
|
|
this._startOutput();
|
|
}
|
|
},
|
|
|
|
outputReady() {
|
|
this._stopOutput();
|
|
},
|
|
|
|
buildError() {
|
|
this._stopOutput();
|
|
},
|
|
|
|
_startOutput() {
|
|
this._discourseProgressLoggerInterval = setInterval(
|
|
this._handleProgress.bind(this),
|
|
CHECK_INTERVAL
|
|
);
|
|
},
|
|
|
|
_handleProgress() {
|
|
const text = progress();
|
|
if (
|
|
text === this._lastText &&
|
|
this._sameOutputCount < REPEAT_DUPLICATE_LOG_ITERATIONS
|
|
) {
|
|
this._sameOutputCount++;
|
|
} else {
|
|
process.stderr.write("..." + (text ? `[${text}]` : ".") + "\n");
|
|
this._sameOutputCount = 0;
|
|
}
|
|
this._lastText = text;
|
|
},
|
|
|
|
_stopOutput() {
|
|
clearInterval(this._discourseProgressLoggerInterval);
|
|
},
|
|
};
|