1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | (function (factory) {
|
---|
9 | if (typeof module === "object" && typeof module.exports === "object") {
|
---|
10 | var v = factory(require, exports);
|
---|
11 | if (v !== undefined) module.exports = v;
|
---|
12 | }
|
---|
13 | else if (typeof define === "function" && define.amd) {
|
---|
14 | define("@angular/compiler-cli/ngcc/src/execution/cluster/master", ["require", "exports", "tslib", "cluster", "@angular/compiler-cli/ngcc/src/execution/tasks/utils", "@angular/compiler-cli/ngcc/src/execution/cluster/utils"], factory);
|
---|
15 | }
|
---|
16 | })(function (require, exports) {
|
---|
17 | "use strict";
|
---|
18 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
19 | exports.ClusterMaster = void 0;
|
---|
20 | var tslib_1 = require("tslib");
|
---|
21 | /// <reference types="node" />
|
---|
22 | var cluster = require("cluster");
|
---|
23 | var utils_1 = require("@angular/compiler-cli/ngcc/src/execution/tasks/utils");
|
---|
24 | var utils_2 = require("@angular/compiler-cli/ngcc/src/execution/cluster/utils");
|
---|
25 | /**
|
---|
26 | * The cluster master is responsible for analyzing all entry-points, planning the work that needs to
|
---|
27 | * be done, distributing it to worker-processes and collecting/post-processing the results.
|
---|
28 | */
|
---|
29 | var ClusterMaster = /** @class */ (function () {
|
---|
30 | function ClusterMaster(maxWorkerCount, fileSystem, logger, fileWriter, pkgJsonUpdater, analyzeEntryPoints, createTaskCompletedCallback) {
|
---|
31 | this.maxWorkerCount = maxWorkerCount;
|
---|
32 | this.fileSystem = fileSystem;
|
---|
33 | this.logger = logger;
|
---|
34 | this.fileWriter = fileWriter;
|
---|
35 | this.pkgJsonUpdater = pkgJsonUpdater;
|
---|
36 | this.finishedDeferred = new utils_2.Deferred();
|
---|
37 | this.processingStartTime = -1;
|
---|
38 | this.taskAssignments = new Map();
|
---|
39 | this.remainingRespawnAttempts = 3;
|
---|
40 | if (!cluster.isMaster) {
|
---|
41 | throw new Error('Tried to instantiate `ClusterMaster` on a worker process.');
|
---|
42 | }
|
---|
43 | // Set the worker entry-point
|
---|
44 | cluster.setupMaster({ exec: this.fileSystem.resolve(__dirname, 'worker.js') });
|
---|
45 | this.taskQueue = analyzeEntryPoints();
|
---|
46 | this.onTaskCompleted = createTaskCompletedCallback(this.taskQueue);
|
---|
47 | }
|
---|
48 | ClusterMaster.prototype.run = function () {
|
---|
49 | var _this = this;
|
---|
50 | if (this.taskQueue.allTasksCompleted) {
|
---|
51 | return Promise.resolve();
|
---|
52 | }
|
---|
53 | // Set up listeners for worker events (emitted on `cluster`).
|
---|
54 | cluster.on('online', this.wrapEventHandler(function (worker) { return _this.onWorkerOnline(worker.id); }));
|
---|
55 | cluster.on('message', this.wrapEventHandler(function (worker, msg) { return _this.onWorkerMessage(worker.id, msg); }));
|
---|
56 | cluster.on('exit', this.wrapEventHandler(function (worker, code, signal) { return _this.onWorkerExit(worker, code, signal); }));
|
---|
57 | // Since we have pending tasks at the very minimum we need a single worker.
|
---|
58 | cluster.fork();
|
---|
59 | return this.finishedDeferred.promise.then(function () { return _this.stopWorkers(); }, function (err) {
|
---|
60 | _this.stopWorkers();
|
---|
61 | return Promise.reject(err);
|
---|
62 | });
|
---|
63 | };
|
---|
64 | /** Try to find available (idle) workers and assign them available (non-blocked) tasks. */
|
---|
65 | ClusterMaster.prototype.maybeDistributeWork = function () {
|
---|
66 | var e_1, _a;
|
---|
67 | var isWorkerAvailable = false;
|
---|
68 | // First, check whether all tasks have been completed.
|
---|
69 | if (this.taskQueue.allTasksCompleted) {
|
---|
70 | var duration = Math.round((Date.now() - this.processingStartTime) / 100) / 10;
|
---|
71 | this.logger.debug("Processed tasks in " + duration + "s.");
|
---|
72 | return this.finishedDeferred.resolve();
|
---|
73 | }
|
---|
74 | try {
|
---|
75 | // Look for available workers and available tasks to assign to them.
|
---|
76 | for (var _b = tslib_1.__values(Array.from(this.taskAssignments)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
---|
77 | var _d = tslib_1.__read(_c.value, 2), workerId = _d[0], assignedTask = _d[1];
|
---|
78 | if (assignedTask !== null) {
|
---|
79 | // This worker already has a job; check other workers.
|
---|
80 | continue;
|
---|
81 | }
|
---|
82 | else {
|
---|
83 | // This worker is available.
|
---|
84 | isWorkerAvailable = true;
|
---|
85 | }
|
---|
86 | // This worker needs a job. See if any are available.
|
---|
87 | var task = this.taskQueue.getNextTask();
|
---|
88 | if (task === null) {
|
---|
89 | // No suitable work available right now.
|
---|
90 | break;
|
---|
91 | }
|
---|
92 | // Process the next task on the worker.
|
---|
93 | this.taskAssignments.set(workerId, { task: task });
|
---|
94 | utils_2.sendMessageToWorker(workerId, { type: 'process-task', task: task });
|
---|
95 | isWorkerAvailable = false;
|
---|
96 | }
|
---|
97 | }
|
---|
98 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
---|
99 | finally {
|
---|
100 | try {
|
---|
101 | if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
---|
102 | }
|
---|
103 | finally { if (e_1) throw e_1.error; }
|
---|
104 | }
|
---|
105 | if (!isWorkerAvailable) {
|
---|
106 | var spawnedWorkerCount = Object.keys(cluster.workers).length;
|
---|
107 | if (spawnedWorkerCount < this.maxWorkerCount) {
|
---|
108 | this.logger.debug('Spawning another worker process as there is more work to be done.');
|
---|
109 | cluster.fork();
|
---|
110 | }
|
---|
111 | else {
|
---|
112 | // If there are no available workers or no available tasks, log (for debugging purposes).
|
---|
113 | this.logger.debug("All " + spawnedWorkerCount + " workers are currently busy and cannot take on more work.");
|
---|
114 | }
|
---|
115 | }
|
---|
116 | else {
|
---|
117 | var busyWorkers = Array.from(this.taskAssignments)
|
---|
118 | .filter(function (_a) {
|
---|
119 | var _b = tslib_1.__read(_a, 2), _workerId = _b[0], task = _b[1];
|
---|
120 | return task !== null;
|
---|
121 | })
|
---|
122 | .map(function (_a) {
|
---|
123 | var _b = tslib_1.__read(_a, 1), workerId = _b[0];
|
---|
124 | return workerId;
|
---|
125 | });
|
---|
126 | var totalWorkerCount = this.taskAssignments.size;
|
---|
127 | var idleWorkerCount = totalWorkerCount - busyWorkers.length;
|
---|
128 | this.logger.debug("No assignments for " + idleWorkerCount + " idle (out of " + totalWorkerCount + " total) " +
|
---|
129 | ("workers. Busy workers: " + busyWorkers.join(', ')));
|
---|
130 | if (busyWorkers.length === 0) {
|
---|
131 | // This is a bug:
|
---|
132 | // All workers are idle (meaning no tasks are in progress) and `taskQueue.allTasksCompleted`
|
---|
133 | // is `false`, but there is still no assignable work.
|
---|
134 | throw new Error('There are still unprocessed tasks in the queue and no tasks are currently in ' +
|
---|
135 | ("progress, yet the queue did not return any available tasks: " + this.taskQueue));
|
---|
136 | }
|
---|
137 | }
|
---|
138 | };
|
---|
139 | /** Handle a worker's exiting. (Might be intentional or not.) */
|
---|
140 | ClusterMaster.prototype.onWorkerExit = function (worker, code, signal) {
|
---|
141 | // If the worker's exiting was intentional, nothing to do.
|
---|
142 | if (worker.exitedAfterDisconnect)
|
---|
143 | return;
|
---|
144 | // The worker exited unexpectedly: Determine it's status and take an appropriate action.
|
---|
145 | var assignment = this.taskAssignments.get(worker.id);
|
---|
146 | this.taskAssignments.delete(worker.id);
|
---|
147 | this.logger.warn("Worker #" + worker.id + " exited unexpectedly (code: " + code + " | signal: " + signal + ").\n" +
|
---|
148 | (" Current task: " + ((assignment == null) ? '-' : utils_1.stringifyTask(assignment.task)) + "\n") +
|
---|
149 | (" Current phase: " + ((assignment == null) ? '-' :
|
---|
150 | (assignment.files == null) ? 'compiling' : 'writing files')));
|
---|
151 | if (assignment == null) {
|
---|
152 | // The crashed worker process was not in the middle of a task:
|
---|
153 | // Just spawn another process.
|
---|
154 | this.logger.debug("Spawning another worker process to replace #" + worker.id + "...");
|
---|
155 | cluster.fork();
|
---|
156 | }
|
---|
157 | else {
|
---|
158 | var task = assignment.task, files = assignment.files;
|
---|
159 | if (files != null) {
|
---|
160 | // The crashed worker process was in the middle of writing transformed files:
|
---|
161 | // Revert any changes before re-processing the task.
|
---|
162 | this.logger.debug("Reverting " + files.length + " transformed files...");
|
---|
163 | this.fileWriter.revertBundle(task.entryPoint, files, task.formatPropertiesToMarkAsProcessed);
|
---|
164 | }
|
---|
165 | // The crashed worker process was in the middle of a task:
|
---|
166 | // Re-add the task back to the queue.
|
---|
167 | this.taskQueue.markAsUnprocessed(task);
|
---|
168 | // The crashing might be a result of increased memory consumption by ngcc.
|
---|
169 | // Do not spawn another process, unless this was the last worker process.
|
---|
170 | var spawnedWorkerCount = Object.keys(cluster.workers).length;
|
---|
171 | if (spawnedWorkerCount > 0) {
|
---|
172 | this.logger.debug("Not spawning another worker process to replace #" + worker.id + ". Continuing with " + spawnedWorkerCount + " workers...");
|
---|
173 | this.maybeDistributeWork();
|
---|
174 | }
|
---|
175 | else if (this.remainingRespawnAttempts > 0) {
|
---|
176 | this.logger.debug("Spawning another worker process to replace #" + worker.id + "...");
|
---|
177 | this.remainingRespawnAttempts--;
|
---|
178 | cluster.fork();
|
---|
179 | }
|
---|
180 | else {
|
---|
181 | throw new Error('All worker processes crashed and attempts to re-spawn them failed. ' +
|
---|
182 | 'Please check your system and ensure there is enough memory available.');
|
---|
183 | }
|
---|
184 | }
|
---|
185 | };
|
---|
186 | /** Handle a message from a worker. */
|
---|
187 | ClusterMaster.prototype.onWorkerMessage = function (workerId, msg) {
|
---|
188 | if (!this.taskAssignments.has(workerId)) {
|
---|
189 | var knownWorkers = Array.from(this.taskAssignments.keys());
|
---|
190 | throw new Error("Received message from unknown worker #" + workerId + " (known workers: " +
|
---|
191 | (knownWorkers.join(', ') + "): " + JSON.stringify(msg)));
|
---|
192 | }
|
---|
193 | switch (msg.type) {
|
---|
194 | case 'error':
|
---|
195 | throw new Error("Error on worker #" + workerId + ": " + msg.error);
|
---|
196 | case 'task-completed':
|
---|
197 | return this.onWorkerTaskCompleted(workerId, msg);
|
---|
198 | case 'transformed-files':
|
---|
199 | return this.onWorkerTransformedFiles(workerId, msg);
|
---|
200 | case 'update-package-json':
|
---|
201 | return this.onWorkerUpdatePackageJson(workerId, msg);
|
---|
202 | default:
|
---|
203 | throw new Error("Invalid message received from worker #" + workerId + ": " + JSON.stringify(msg));
|
---|
204 | }
|
---|
205 | };
|
---|
206 | /** Handle a worker's coming online. */
|
---|
207 | ClusterMaster.prototype.onWorkerOnline = function (workerId) {
|
---|
208 | if (this.taskAssignments.has(workerId)) {
|
---|
209 | throw new Error("Invariant violated: Worker #" + workerId + " came online more than once.");
|
---|
210 | }
|
---|
211 | if (this.processingStartTime === -1) {
|
---|
212 | this.logger.debug('Processing tasks...');
|
---|
213 | this.processingStartTime = Date.now();
|
---|
214 | }
|
---|
215 | this.taskAssignments.set(workerId, null);
|
---|
216 | this.maybeDistributeWork();
|
---|
217 | };
|
---|
218 | /** Handle a worker's having completed their assigned task. */
|
---|
219 | ClusterMaster.prototype.onWorkerTaskCompleted = function (workerId, msg) {
|
---|
220 | var assignment = this.taskAssignments.get(workerId) || null;
|
---|
221 | if (assignment === null) {
|
---|
222 | throw new Error("Expected worker #" + workerId + " to have a task assigned, while handling message: " +
|
---|
223 | JSON.stringify(msg));
|
---|
224 | }
|
---|
225 | this.onTaskCompleted(assignment.task, msg.outcome, msg.message);
|
---|
226 | this.taskQueue.markAsCompleted(assignment.task);
|
---|
227 | this.taskAssignments.set(workerId, null);
|
---|
228 | this.maybeDistributeWork();
|
---|
229 | };
|
---|
230 | /** Handle a worker's message regarding the files transformed while processing its task. */
|
---|
231 | ClusterMaster.prototype.onWorkerTransformedFiles = function (workerId, msg) {
|
---|
232 | var assignment = this.taskAssignments.get(workerId) || null;
|
---|
233 | if (assignment === null) {
|
---|
234 | throw new Error("Expected worker #" + workerId + " to have a task assigned, while handling message: " +
|
---|
235 | JSON.stringify(msg));
|
---|
236 | }
|
---|
237 | var oldFiles = assignment.files;
|
---|
238 | var newFiles = msg.files;
|
---|
239 | if (oldFiles !== undefined) {
|
---|
240 | throw new Error("Worker #" + workerId + " reported transformed files more than once.\n" +
|
---|
241 | (" Old files (" + oldFiles.length + "): [" + oldFiles.join(', ') + "]\n") +
|
---|
242 | (" New files (" + newFiles.length + "): [" + newFiles.join(', ') + "]\n"));
|
---|
243 | }
|
---|
244 | assignment.files = newFiles;
|
---|
245 | };
|
---|
246 | /** Handle a worker's request to update a `package.json` file. */
|
---|
247 | ClusterMaster.prototype.onWorkerUpdatePackageJson = function (workerId, msg) {
|
---|
248 | var assignment = this.taskAssignments.get(workerId) || null;
|
---|
249 | if (assignment === null) {
|
---|
250 | throw new Error("Expected worker #" + workerId + " to have a task assigned, while handling message: " +
|
---|
251 | JSON.stringify(msg));
|
---|
252 | }
|
---|
253 | var entryPoint = assignment.task.entryPoint;
|
---|
254 | var expectedPackageJsonPath = this.fileSystem.resolve(entryPoint.path, 'package.json');
|
---|
255 | if (expectedPackageJsonPath !== msg.packageJsonPath) {
|
---|
256 | throw new Error("Received '" + msg.type + "' message from worker #" + workerId + " for '" + msg.packageJsonPath + "', " +
|
---|
257 | ("but was expecting '" + expectedPackageJsonPath + "' (based on task assignment)."));
|
---|
258 | }
|
---|
259 | // NOTE: Although the change in the parsed `package.json` will be reflected in tasks objects
|
---|
260 | // locally and thus also in future `process-task` messages sent to worker processes, any
|
---|
261 | // processes already running and processing a task for the same entry-point will not get
|
---|
262 | // the change.
|
---|
263 | // Do not rely on having an up-to-date `package.json` representation in worker processes.
|
---|
264 | // In other words, task processing should only rely on the info that was there when the
|
---|
265 | // file was initially parsed (during entry-point analysis) and not on the info that might
|
---|
266 | // be added later (during task processing).
|
---|
267 | this.pkgJsonUpdater.writeChanges(msg.changes, msg.packageJsonPath, entryPoint.packageJson);
|
---|
268 | };
|
---|
269 | /** Stop all workers and stop listening on cluster events. */
|
---|
270 | ClusterMaster.prototype.stopWorkers = function () {
|
---|
271 | var workers = Object.values(cluster.workers);
|
---|
272 | this.logger.debug("Stopping " + workers.length + " workers...");
|
---|
273 | cluster.removeAllListeners();
|
---|
274 | workers.forEach(function (worker) { return worker.kill(); });
|
---|
275 | };
|
---|
276 | /**
|
---|
277 | * Wrap an event handler to ensure that `finishedDeferred` will be rejected on error (regardless
|
---|
278 | * if the handler completes synchronously or asynchronously).
|
---|
279 | */
|
---|
280 | ClusterMaster.prototype.wrapEventHandler = function (fn) {
|
---|
281 | var _this = this;
|
---|
282 | return function () {
|
---|
283 | var args = [];
|
---|
284 | for (var _i = 0; _i < arguments.length; _i++) {
|
---|
285 | args[_i] = arguments[_i];
|
---|
286 | }
|
---|
287 | return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
---|
288 | var err_1;
|
---|
289 | return tslib_1.__generator(this, function (_a) {
|
---|
290 | switch (_a.label) {
|
---|
291 | case 0:
|
---|
292 | _a.trys.push([0, 2, , 3]);
|
---|
293 | return [4 /*yield*/, fn.apply(void 0, tslib_1.__spreadArray([], tslib_1.__read(args)))];
|
---|
294 | case 1:
|
---|
295 | _a.sent();
|
---|
296 | return [3 /*break*/, 3];
|
---|
297 | case 2:
|
---|
298 | err_1 = _a.sent();
|
---|
299 | this.finishedDeferred.reject(err_1);
|
---|
300 | return [3 /*break*/, 3];
|
---|
301 | case 3: return [2 /*return*/];
|
---|
302 | }
|
---|
303 | });
|
---|
304 | });
|
---|
305 | };
|
---|
306 | };
|
---|
307 | return ClusterMaster;
|
---|
308 | }());
|
---|
309 | exports.ClusterMaster = ClusterMaster;
|
---|
310 | });
|
---|
311 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWFzdGVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvY29tcGlsZXItY2xpL25nY2Mvc3JjL2V4ZWN1dGlvbi9jbHVzdGVyL21hc3Rlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7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