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 | /// <reference types="node" />
|
---|
9 | (function (factory) {
|
---|
10 | if (typeof module === "object" && typeof module.exports === "object") {
|
---|
11 | var v = factory(require, exports);
|
---|
12 | if (v !== undefined) module.exports = v;
|
---|
13 | }
|
---|
14 | else if (typeof define === "function" && define.amd) {
|
---|
15 | define("@angular/compiler-cli/ngcc/src/execution/cluster/worker", ["require", "exports", "tslib", "cluster", "@angular/compiler-cli/ngcc/src/command_line_options", "@angular/compiler-cli/ngcc/src/ngcc_options", "@angular/compiler-cli/ngcc/src/execution/create_compile_function", "@angular/compiler-cli/ngcc/src/execution/tasks/utils", "@angular/compiler-cli/ngcc/src/execution/cluster/package_json_updater", "@angular/compiler-cli/ngcc/src/execution/cluster/utils"], factory);
|
---|
16 | }
|
---|
17 | })(function (require, exports) {
|
---|
18 | "use strict";
|
---|
19 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
20 | exports.startWorker = void 0;
|
---|
21 | var tslib_1 = require("tslib");
|
---|
22 | var cluster = require("cluster");
|
---|
23 | var command_line_options_1 = require("@angular/compiler-cli/ngcc/src/command_line_options");
|
---|
24 | var ngcc_options_1 = require("@angular/compiler-cli/ngcc/src/ngcc_options");
|
---|
25 | var create_compile_function_1 = require("@angular/compiler-cli/ngcc/src/execution/create_compile_function");
|
---|
26 | var utils_1 = require("@angular/compiler-cli/ngcc/src/execution/tasks/utils");
|
---|
27 | var package_json_updater_1 = require("@angular/compiler-cli/ngcc/src/execution/cluster/package_json_updater");
|
---|
28 | var utils_2 = require("@angular/compiler-cli/ngcc/src/execution/cluster/utils");
|
---|
29 | // Cluster worker entry point
|
---|
30 | if (require.main === module) {
|
---|
31 | (function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
---|
32 | var _a, logger, pathMappings, enableI18nLegacyMessageIdFormat, fileSystem, tsConfig, getFileWriter, pkgJsonUpdater, fileWriter, createCompileFn, e_1;
|
---|
33 | return tslib_1.__generator(this, function (_b) {
|
---|
34 | switch (_b.label) {
|
---|
35 | case 0:
|
---|
36 | process.title = 'ngcc (worker)';
|
---|
37 | _b.label = 1;
|
---|
38 | case 1:
|
---|
39 | _b.trys.push([1, 3, , 4]);
|
---|
40 | _a = ngcc_options_1.getSharedSetup(command_line_options_1.parseCommandLineOptions(process.argv.slice(2))), logger = _a.logger, pathMappings = _a.pathMappings, enableI18nLegacyMessageIdFormat = _a.enableI18nLegacyMessageIdFormat, fileSystem = _a.fileSystem, tsConfig = _a.tsConfig, getFileWriter = _a.getFileWriter;
|
---|
41 | pkgJsonUpdater = new package_json_updater_1.ClusterWorkerPackageJsonUpdater();
|
---|
42 | fileWriter = getFileWriter(pkgJsonUpdater);
|
---|
43 | createCompileFn = create_compile_function_1.getCreateCompileFn(fileSystem, logger, fileWriter, enableI18nLegacyMessageIdFormat, tsConfig, pathMappings);
|
---|
44 | return [4 /*yield*/, startWorker(logger, createCompileFn)];
|
---|
45 | case 2:
|
---|
46 | _b.sent();
|
---|
47 | process.exitCode = 0;
|
---|
48 | return [3 /*break*/, 4];
|
---|
49 | case 3:
|
---|
50 | e_1 = _b.sent();
|
---|
51 | console.error(e_1.stack || e_1.message);
|
---|
52 | process.exit(1);
|
---|
53 | return [3 /*break*/, 4];
|
---|
54 | case 4: return [2 /*return*/];
|
---|
55 | }
|
---|
56 | });
|
---|
57 | }); })();
|
---|
58 | }
|
---|
59 | function startWorker(logger, createCompileFn) {
|
---|
60 | return tslib_1.__awaiter(this, void 0, void 0, function () {
|
---|
61 | var compile;
|
---|
62 | var _this = this;
|
---|
63 | return tslib_1.__generator(this, function (_a) {
|
---|
64 | if (cluster.isMaster) {
|
---|
65 | throw new Error('Tried to run cluster worker on the master process.');
|
---|
66 | }
|
---|
67 | compile = createCompileFn(function (transformedFiles) { return utils_2.sendMessageToMaster({
|
---|
68 | type: 'transformed-files',
|
---|
69 | files: transformedFiles.map(function (f) { return f.path; }),
|
---|
70 | }); }, function (_task, outcome, message) { return utils_2.sendMessageToMaster({ type: 'task-completed', outcome: outcome, message: message }); });
|
---|
71 | // Listen for `ProcessTaskMessage`s and process tasks.
|
---|
72 | cluster.worker.on('message', function (msg) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
---|
73 | var _a, err_1, _b;
|
---|
74 | return tslib_1.__generator(this, function (_c) {
|
---|
75 | switch (_c.label) {
|
---|
76 | case 0:
|
---|
77 | _c.trys.push([0, 5, , 10]);
|
---|
78 | _a = msg.type;
|
---|
79 | switch (_a) {
|
---|
80 | case 'process-task': return [3 /*break*/, 1];
|
---|
81 | }
|
---|
82 | return [3 /*break*/, 3];
|
---|
83 | case 1:
|
---|
84 | logger.debug("[Worker #" + cluster.worker.id + "] Processing task: " + utils_1.stringifyTask(msg.task));
|
---|
85 | return [4 /*yield*/, compile(msg.task)];
|
---|
86 | case 2: return [2 /*return*/, _c.sent()];
|
---|
87 | case 3: throw new Error("[Worker #" + cluster.worker.id + "] Invalid message received: " + JSON.stringify(msg));
|
---|
88 | case 4: return [3 /*break*/, 10];
|
---|
89 | case 5:
|
---|
90 | err_1 = _c.sent();
|
---|
91 | _b = err_1 && err_1.code;
|
---|
92 | switch (_b) {
|
---|
93 | case 'ENOMEM': return [3 /*break*/, 6];
|
---|
94 | }
|
---|
95 | return [3 /*break*/, 7];
|
---|
96 | case 6:
|
---|
97 | // Not being able to allocate enough memory is not necessarily a problem with processing
|
---|
98 | // the current task. It could just mean that there are too many tasks being processed
|
---|
99 | // simultaneously.
|
---|
100 | //
|
---|
101 | // Exit with an error and let the cluster master decide how to handle this.
|
---|
102 | logger.warn("[Worker #" + cluster.worker.id + "] " + (err_1.stack || err_1.message));
|
---|
103 | return [2 /*return*/, process.exit(1)];
|
---|
104 | case 7: return [4 /*yield*/, utils_2.sendMessageToMaster({
|
---|
105 | type: 'error',
|
---|
106 | error: (err_1 instanceof Error) ? (err_1.stack || err_1.message) : err_1,
|
---|
107 | })];
|
---|
108 | case 8:
|
---|
109 | _c.sent();
|
---|
110 | _c.label = 9;
|
---|
111 | case 9: return [3 /*break*/, 10];
|
---|
112 | case 10: return [2 /*return*/];
|
---|
113 | }
|
---|
114 | });
|
---|
115 | }); });
|
---|
116 | // Return a promise that is never resolved.
|
---|
117 | return [2 /*return*/, new Promise(function () { return undefined; })];
|
---|
118 | });
|
---|
119 | });
|
---|
120 | }
|
---|
121 | exports.startWorker = startWorker;
|
---|
122 | });
|
---|
123 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid29ya2VyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvY29tcGlsZXItY2xpL25nY2Mvc3JjL2V4ZWN1dGlvbi9jbHVzdGVyL3dvcmtlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFDSCw4QkFBOEI7Ozs7Ozs7Ozs7Ozs7O0lBRTlCLGlDQUFtQztJQUduQyw0RkFBbUU7SUFDbkUsNEVBQWtEO0lBRWxELDRHQUE4RDtJQUM5RCw4RUFBNkM7SUFHN0MsOEdBQXVFO0lBQ3ZFLGdGQUE0QztJQUU1Qyw2QkFBNkI7SUFDN0IsSUFBSSxPQUFPLENBQUMsSUFBSSxLQUFLLE1BQU0sRUFBRTtRQUMzQixDQUFDOzs7Ozt3QkFDQyxPQUFPLENBQUMsS0FBSyxHQUFHLGVBQWUsQ0FBQzs7Ozt3QkFHeEIsS0FPRiw2QkFBYyxDQUFDLDhDQUF1QixDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUMsS0FBSyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsRUFOaEUsTUFBTSxZQUFBLEVBQ04sWUFBWSxrQkFBQSx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