zcatalyst-cli 1.25.2 → 1.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api-timer.d.ts +0 -1
- package/lib/apig-utils.d.ts +1 -1
- package/lib/apig-utils.js +1 -1
- package/lib/appsail-utils.js +80 -13
- package/lib/archiver.d.ts +0 -4
- package/lib/archiver.js +21 -11
- package/lib/authentication/constants/auth.js +1 -1
- package/lib/authentication/credential.js +3 -3
- package/lib/authentication/index.js +25 -14
- package/lib/authentication/login.d.ts +0 -2
- package/lib/authentication/login.js +23 -10
- package/lib/bin/catalyst.js +17 -7
- package/lib/client-utils.d.ts +3 -3
- package/lib/client-utils.js +2 -2
- package/lib/client.js +19 -9
- package/lib/code-deck.d.ts +0 -2
- package/lib/code-deck.js +4 -4
- package/lib/command_needs/config.js +1 -1
- package/lib/command_needs/rc.js +5 -2
- package/lib/commands/appsail/add.js +17 -7
- package/lib/commands/client/setup.js +17 -7
- package/lib/commands/config/set.js +5 -3
- package/lib/commands/deploy/appsail.js +37 -14
- package/lib/commands/deploy/index.js +88 -66
- package/lib/commands/deploy/slate.js +37 -14
- package/lib/commands/event/generate/integ.js +18 -9
- package/lib/commands/functions/add.js +17 -7
- package/lib/commands/functions/execute.js +17 -7
- package/lib/commands/functions/setup.js +17 -7
- package/lib/commands/functions/shell.js +17 -7
- package/lib/commands/iac/import.js +18 -8
- package/lib/commands/iac/pack.js +17 -7
- package/lib/commands/iac/status.js +17 -7
- package/lib/commands/index.js +20 -12
- package/lib/commands/init.js +17 -7
- package/lib/commands/login.js +17 -7
- package/lib/commands/logout.js +17 -7
- package/lib/commands/project/list.js +17 -7
- package/lib/commands/project/use.js +1 -0
- package/lib/commands/pull.js +17 -7
- package/lib/commands/run.js +17 -7
- package/lib/commands/serve.js +17 -7
- package/lib/commands/signals/generate/index.js +1 -1
- package/lib/commands/slate/create.js +17 -7
- package/lib/commands/slate/link.js +18 -7
- package/lib/commands/slate/unlink.js +16 -4
- package/lib/commands/token/generate.js +17 -7
- package/lib/commands/token/list.js +17 -7
- package/lib/commands/token/revoke.js +17 -7
- package/lib/commands/zest/generate/index.js +21 -11
- package/lib/deploy/features/appsail/index.js +2 -3
- package/lib/deploy/features/appsail/pack.d.ts +0 -1
- package/lib/deploy/features/appsail/pack.js +2 -3
- package/lib/deploy/features/appsail/utils.js +7 -8
- package/lib/deploy/features/functions/languages/index.js +3 -4
- package/lib/deploy/features/index.js +17 -7
- package/lib/deploy/features/slate.js +2 -3
- package/lib/deploy/index.js +2 -2
- package/lib/deploy/util.d.ts +2 -0
- package/lib/deploy/util.js +3 -1
- package/lib/docs/commands/signals/generate/generate.toml +19 -0
- package/lib/docs/commands/slate/unlink.toml +9 -0
- package/lib/docs/fn-utils/lib/node.toml +4 -0
- package/lib/docs/init/dependencies/python/ensure-python.toml +4 -0
- package/lib/docs/serve/server/lib/slate/index.toml +15 -0
- package/lib/docs/slate-utils.toml +9 -0
- package/lib/endpoints/index.d.ts +2 -1
- package/lib/endpoints/index.js +88 -79
- package/lib/endpoints/lib/apig.d.ts +0 -1
- package/lib/endpoints/lib/apig.js +2 -2
- package/lib/endpoints/lib/applogic.d.ts +0 -1
- package/lib/endpoints/lib/applogic.js +2 -2
- package/lib/endpoints/lib/appsail.d.ts +1 -4
- package/lib/endpoints/lib/appsail.js +7 -7
- package/lib/endpoints/lib/client.d.ts +0 -1
- package/lib/endpoints/lib/code-deck.js +1 -1
- package/lib/endpoints/lib/common.d.ts +0 -2
- package/lib/endpoints/lib/ds-bulk.js +2 -2
- package/lib/endpoints/lib/env.js +2 -2
- package/lib/endpoints/lib/filestore.d.ts +0 -1
- package/lib/endpoints/lib/functions.d.ts +0 -1
- package/lib/endpoints/lib/functions.js +2 -2
- package/lib/endpoints/lib/git-hub.d.ts +0 -2
- package/lib/endpoints/lib/iac.d.ts +0 -3
- package/lib/endpoints/lib/iac.js +2 -2
- package/lib/endpoints/lib/project.d.ts +0 -1
- package/lib/endpoints/lib/project.js +2 -2
- package/lib/endpoints/lib/sdk.d.ts +0 -2
- package/lib/endpoints/lib/sdk.js +1 -1
- package/lib/endpoints/lib/slate.d.ts +0 -1
- package/lib/endpoints/lib/stratus.d.ts +0 -1
- package/lib/endpoints/lib/user.d.ts +0 -2
- package/lib/endpoints/lib/user.js +2 -1
- package/lib/error/context-help.js +1 -1
- package/lib/error/index.js +2 -2
- package/lib/event_generate/cache.js +4 -4
- package/lib/event_generate/custom.js +1 -2
- package/lib/event_generate/datastore.js +4 -4
- package/lib/event_generate/filestore.js +4 -4
- package/lib/event_generate/github.js +2 -2
- package/lib/event_generate/index.js +19 -11
- package/lib/event_generate/stratus.js +2 -2
- package/lib/event_generate/user.js +2 -2
- package/lib/event_generate/webapp.js +2 -2
- package/lib/execute/caller.d.ts +0 -1
- package/lib/execute/caller.js +20 -7
- package/lib/execute/index.js +27 -4
- package/lib/execute-script.js +22 -13
- package/lib/express_middlewares/auth-checker.js +2 -3
- package/lib/express_middlewares/project.d.ts +1 -1
- package/lib/fn-utils/index.js +17 -7
- package/lib/fn-utils/lib/browserLogic.js +4 -5
- package/lib/fn-utils/lib/common.d.ts +0 -1
- package/lib/fn-utils/lib/common.js +25 -26
- package/lib/fn-utils/lib/integ.js +2 -3
- package/lib/fn-utils/lib/java/classpath.js +2 -3
- package/lib/fn-utils/lib/java/compile.js +4 -4
- package/lib/fn-utils/lib/java/ensure-java-userconfig.d.ts +10 -0
- package/lib/fn-utils/lib/java/ensure-java-userconfig.js +45 -23
- package/lib/fn-utils/lib/java/index.d.ts +0 -1
- package/lib/fn-utils/lib/java/index.js +11 -11
- package/lib/fn-utils/lib/java/keywords.js +2 -2
- package/lib/fn-utils/lib/node.d.ts +1 -1
- package/lib/fn-utils/lib/node.js +67 -15
- package/lib/fn-utils/lib/python.js +29 -19
- package/lib/iac/status/util/index.d.ts +1 -1
- package/lib/init/dependencies/npm-install.js +2 -2
- package/lib/init/dependencies/python/ensure-python.d.ts +2 -2
- package/lib/init/dependencies/python/ensure-python.js +65 -58
- package/lib/init/dependencies/python/pip-install.d.ts +3 -5
- package/lib/init/dependencies/python/pip-install.js +14 -53
- package/lib/init/features/appsail/utils.js +21 -12
- package/lib/init/features/client/index.js +18 -9
- package/lib/init/features/client/initializers/angular.js +17 -7
- package/lib/init/features/client/initializers/basic.js +17 -7
- package/lib/init/features/client/initializers/lyte.js +17 -7
- package/lib/init/features/client/initializers/react.js +17 -7
- package/lib/init/features/index.js +29 -20
- package/lib/init/features/project.js +5 -5
- package/lib/init/features/slate/index.js +198 -69
- package/lib/init/util/client.js +23 -13
- package/lib/init/util/common.js +5 -6
- package/lib/init/util/project.js +1 -1
- package/lib/internal/api.d.ts +0 -3
- package/lib/internal/api.js +19 -9
- package/lib/internal/command.js +18 -9
- package/lib/migration/global/1.25.0.d.ts +2 -0
- package/lib/migration/global/1.25.0.js +28 -0
- package/lib/migration/index.js +20 -12
- package/lib/option-filter.js +19 -10
- package/lib/optional-import.js +19 -10
- package/lib/plugin-loader.d.ts +0 -2
- package/lib/plugin-loader.js +18 -8
- package/lib/port-resolver.js +10 -10
- package/lib/prompt/index.d.ts +3 -3
- package/lib/prompt/index.js +17 -7
- package/lib/prompt/types/file-path.d.ts +0 -1
- package/lib/prompt/types/search-box.d.ts +0 -1
- package/lib/prompt/types/tree.d.ts +1 -2
- package/lib/prompt/types/tree.js +10 -10
- package/lib/prompt/types/with-description.d.ts +0 -1
- package/lib/pull/features/functions/index.js +71 -52
- package/lib/pull/features/functions/languages.js +3 -4
- package/lib/pull/features/index.js +17 -7
- package/lib/repl-server.d.ts +0 -1
- package/lib/repl-server.js +9 -1
- package/lib/serve/features/apig.js +19 -1
- package/lib/serve/features/appsail.d.ts +1 -0
- package/lib/serve/features/appsail.js +51 -7
- package/lib/serve/features/index.js +22 -13
- package/lib/serve/index.js +20 -7
- package/lib/serve/server/index.d.ts +0 -2
- package/lib/serve/server/index.js +26 -12
- package/lib/serve/server/lib/appsail/index.js +31 -37
- package/lib/serve/server/lib/appsail/start.js +12 -5
- package/lib/serve/server/lib/appsail/util.d.ts +11 -0
- package/lib/serve/server/lib/appsail/util.js +69 -0
- package/lib/serve/server/lib/java/index.js +18 -7
- package/lib/serve/server/lib/master/appsail.js +3 -4
- package/lib/serve/server/lib/master/functions.js +1 -2
- package/lib/serve/server/lib/master/index.d.ts +0 -1
- package/lib/serve/server/lib/master/index.js +5 -5
- package/lib/serve/server/lib/master/slate.js +1 -2
- package/lib/serve/server/lib/master/unknown-req-proxy.js +5 -2
- package/lib/serve/server/lib/master/utils.d.ts +4 -8
- package/lib/serve/server/lib/master/utils.js +4 -6
- package/lib/serve/server/lib/master/web-client.js +1 -2
- package/lib/serve/server/lib/node/index.js +22 -11
- package/lib/serve/server/lib/node/server/browserlogic/utils/playwright-handler.js +1 -1
- package/lib/serve/server/lib/node/server/browserlogic/utils/puppeteer-handler.js +1 -1
- package/lib/serve/server/lib/node/server/browserlogic/utils/selenium-handler.js +2 -0
- package/lib/serve/server/lib/python/index.js +23 -14
- package/lib/serve/server/lib/slate/static-server.d.ts +0 -1
- package/lib/serve/server/lib/slate/static-server.js +5 -4
- package/lib/serve/server/lib/web_client/server.d.ts +0 -1
- package/lib/serve/server/lib/web_client/server.js +5 -4
- package/lib/shell/dependencies/http-functions.d.ts +0 -2
- package/lib/shell/dependencies/http-functions.js +7 -7
- package/lib/shell/dependencies/non-http-function/fn-execution-handler.d.ts +0 -2
- package/lib/shell/dependencies/non-http-function/fn-execution-handler.js +55 -24
- package/lib/shell/dependencies/non-http-function/fn-handler.d.ts +3 -3
- package/lib/shell/dependencies/non-http-function/fn-handler.js +54 -20
- package/lib/shell/dependencies/non-http-function/node.js +4 -4
- package/lib/shell/dependencies/non-http-function/python.d.ts +1 -1
- package/lib/shell/dependencies/non-http-function/python.js +11 -13
- package/lib/shell/dependencies/non-http-function/slave-manager.d.ts +0 -2
- package/lib/shell/dependencies/non-http-function/slave-manager.js +11 -7
- package/lib/shell/dependencies/tunnel-server.js +4 -4
- package/lib/shell/index.js +50 -3
- package/lib/shell/prepare/index.js +4 -3
- package/lib/shell/prepare/languages/index.js +18 -9
- package/lib/shell/prepare/languages/node.js +29 -19
- package/lib/shell/prepare/languages/python.js +6 -12
- package/lib/signals/index.js +19 -11
- package/lib/slate-utils.js +4 -3
- package/lib/throbber/index.d.ts +1 -2
- package/lib/throbber/index.js +5 -2
- package/lib/throbber/utils.d.ts +0 -1
- package/lib/throbber/utils.js +4 -5
- package/lib/userConfig.d.ts +14 -0
- package/lib/userConfig.js +15 -1
- package/lib/util_modules/config/index.js +17 -7
- package/lib/util_modules/config/lib/apig.d.ts +1 -0
- package/lib/util_modules/config/lib/apig.js +10 -5
- package/lib/util_modules/config/lib/appsail.js +7 -7
- package/lib/util_modules/config/lib/client.js +5 -6
- package/lib/util_modules/config/lib/functions.js +5 -6
- package/lib/util_modules/config/lib/slate.js +5 -6
- package/lib/util_modules/config-store.d.ts +1 -1
- package/lib/util_modules/config-store.js +30 -13
- package/lib/util_modules/constants/lib/apig-rules.d.ts +1 -1
- package/lib/util_modules/constants/lib/dc-type.js +3 -3
- package/lib/util_modules/constants/lib/placeholders.d.ts +1 -1
- package/lib/util_modules/constants/lib/placeholders.js +1 -1
- package/lib/util_modules/constants/lib/urls.js +2 -9
- package/lib/util_modules/container.js +23 -14
- package/lib/util_modules/dc.js +3 -4
- package/lib/util_modules/env.d.ts +3 -0
- package/lib/util_modules/env.js +64 -4
- package/lib/util_modules/event-emitter.d.ts +9 -0
- package/lib/util_modules/event-emitter.js +68 -0
- package/lib/util_modules/fs/index.js +17 -7
- package/lib/util_modules/fs/lib/async.d.ts +0 -4
- package/lib/util_modules/fs/lib/async.js +46 -46
- package/lib/util_modules/fs/lib/sync.d.ts +1 -3
- package/lib/util_modules/fs/lib/sync.js +40 -30
- package/lib/util_modules/logger/index.js +12 -12
- package/lib/util_modules/logger/utils.d.ts +0 -4
- package/lib/util_modules/logger/utils.js +1 -1
- package/lib/util_modules/logger/winston.js +2 -2
- package/lib/util_modules/option.js +5 -6
- package/lib/util_modules/project.js +22 -23
- package/lib/util_modules/runtime-store.d.ts +2 -2
- package/lib/util_modules/server.d.ts +1 -2
- package/lib/util_modules/server.js +54 -15
- package/lib/util_modules/shell.d.ts +0 -3
- package/lib/util_modules/shell.js +5 -6
- package/lib/util_modules/toml.js +2 -3
- package/package.json +13 -13
- package/templates/init/functions/java/event/sample.java +5 -2
- package/templates/web-socket.txt +1 -1
- /package/lib/docs/{commands/event/generate → event_generate}/index.toml +0 -0
- /package/templates/init/functions/java/integ/convokraft/{Sample.java → sample.java} +0 -0
|
@@ -24,6 +24,8 @@ async function getBrowser() {
|
|
|
24
24
|
options.addArguments('--headless') ;
|
|
25
25
|
options.addArguments('--disable-dev-shm-usage');
|
|
26
26
|
options.addArguments('--remote-debugging-port=9002');
|
|
27
|
+
options.addArguments('--no-sandbox');
|
|
28
|
+
options.addArguments('--disable-setuid-sandbox');
|
|
27
29
|
|
|
28
30
|
const chromeCapabilities = webdriver.Capabilities.chrome();
|
|
29
31
|
driver = new webdriver.Builder()
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -38,7 +48,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
38
48
|
const path_1 = require("path");
|
|
39
49
|
const runtime_store_1 = __importDefault(require("../../../../runtime-store"));
|
|
40
50
|
const http_functions_1 = require("../../../../shell/dependencies/http-functions");
|
|
41
|
-
const userConfig_1 = __importDefault(require("../../../../userConfig"));
|
|
42
51
|
const constants_1 = require("../../../../util_modules/constants");
|
|
43
52
|
const project_1 = require("../../../../util_modules/project");
|
|
44
53
|
const shell_1 = require("../../../../util_modules/shell");
|
|
@@ -83,22 +92,22 @@ exports.default = (details) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
83
92
|
}
|
|
84
93
|
opts.unshift('-u');
|
|
85
94
|
return new Promise((resolve, reject) => {
|
|
86
|
-
var _a, _b;
|
|
87
|
-
const child = (0, shell_1.spawn)(
|
|
95
|
+
var _a, _b, _c, _d;
|
|
96
|
+
const child = (0, shell_1.spawn)(((_b = (_a = details.target) === null || _a === void 0 ? void 0 : _a.additionalInfo) === null || _b === void 0 ? void 0 : _b.binPath) || 'python', opts, {
|
|
88
97
|
cwd: codeLocation,
|
|
89
98
|
stdio: 'pipe',
|
|
90
99
|
detached: true,
|
|
91
|
-
env: Object.assign({ X_ZOHO_CATALYST_IS_LOCAL: 'true', X_ZOHO_CATALYST_FUNCTION_LOADED: 'true', X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth, X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin, X_ZOHO_CATALYST_RESOURCE_ID: (
|
|
100
|
+
env: Object.assign({ X_ZOHO_CATALYST_IS_LOCAL: 'true', X_ZOHO_CATALYST_FUNCTION_LOADED: 'true', X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth, X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin, X_ZOHO_CATALYST_RESOURCE_ID: (_c = details.target) === null || _c === void 0 ? void 0 : _c.id, X_ZOHO_STRATUS_RESOURCE_SUFFIX: constants_1.ORIGIN.stratusSuffix, X_ZOHO_CATALYST_CODE_LOCATION: targetSource === null || targetSource === void 0 ? void 0 : targetSource.replace(projectRoot, (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build)), X_ZOHO_CATALYST_SERVER_LISTEN_PORT: details.httpPort.toString(), CATALYST_PORTAL_DOMAIN: constants_1.ORIGIN.iamPortal, CATALYST_PROJECT_TIMEZONE: (0, project_1.getProjectTimezone)(Intl.DateTimeFormat().resolvedOptions().timeZone) }, details.target.env_var)
|
|
92
101
|
}).RAW();
|
|
93
102
|
child.on('spawn', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
94
|
-
var
|
|
103
|
+
var _a;
|
|
95
104
|
yield (0, http_functions_1.checkIfRuntimeServerRunning)(details.httpPort.toString());
|
|
96
105
|
debugConfig &&
|
|
97
|
-
(0, index_1.info)(`\nPython debugger for function ${(
|
|
106
|
+
(0, index_1.info)(`\nPython debugger for function ${(_a = details.target) === null || _a === void 0 ? void 0 : _a.name} listening on port: ${details.debugPort}`);
|
|
98
107
|
resolve(child);
|
|
99
108
|
}));
|
|
100
109
|
const errData = [];
|
|
101
|
-
(
|
|
110
|
+
(_d = child.stderr) === null || _d === void 0 ? void 0 : _d.on('data', (chunk) => {
|
|
102
111
|
errData.push(chunk);
|
|
103
112
|
});
|
|
104
113
|
child.on('error', (err) => {
|
|
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.default = slateServer;
|
|
15
16
|
const express_1 = __importDefault(require("express"));
|
|
16
17
|
const events_1 = require("events");
|
|
17
18
|
const chokidar_1 = require("chokidar");
|
|
@@ -24,13 +25,14 @@ const ws_1 = require("ws");
|
|
|
24
25
|
const port_resolver_js_1 = __importDefault(require("../../../../port-resolver.js"));
|
|
25
26
|
const ansi_colors_1 = require("ansi-colors");
|
|
26
27
|
const server_js_1 = require("../../../../util_modules/server.js");
|
|
28
|
+
const env_1 = require("../../../../util_modules/env");
|
|
27
29
|
function prepareScriptFile(dir, port) {
|
|
28
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29
31
|
const scriptFile = yield index_js_1.ASYNC.readFile(constants_1.TEMPLATE.client.basic.socket);
|
|
30
32
|
if (!scriptFile) {
|
|
31
33
|
throw new error_1.default('Unable to read the script file', { exit: 2 });
|
|
32
34
|
}
|
|
33
|
-
const scriptReady = scriptFile.replace(new RegExp(constants_1.PLACEHOLDER.client.
|
|
35
|
+
const scriptReady = scriptFile.replace(new RegExp(constants_1.PLACEHOLDER.client.domain, 'g'), (0, env_1.getLocalAccessDomain)(port, 'ws'));
|
|
34
36
|
yield index_js_1.ASYNC.ensureDir(dir);
|
|
35
37
|
const scriptFilePath = (0, path_1.join)(dir, 'reload-script.js');
|
|
36
38
|
yield index_js_1.ASYNC.writeFile(scriptFilePath, scriptReady);
|
|
@@ -59,8 +61,8 @@ function reloadApp(event, path, liveSockets) {
|
|
|
59
61
|
(0, logger_1.info)((0, ansi_colors_1.cyan)(`${event} detected in ${path} of the Web-Client.`));
|
|
60
62
|
liveSockets.forEach((socket) => socket.send('reload'));
|
|
61
63
|
}
|
|
62
|
-
function slateServer(
|
|
63
|
-
return __awaiter(this,
|
|
64
|
+
function slateServer(httpPort_1, source_1) {
|
|
65
|
+
return __awaiter(this, arguments, void 0, function* (httpPort, source, { homepage = '/index.html', enableWatch = true, notFoundPage } = {}) {
|
|
64
66
|
const eventListener = new events_1.EventEmitter();
|
|
65
67
|
const catalystTempDir = (0, path_1.join)(source, '.catalyst');
|
|
66
68
|
const socketServerPort = yield port_resolver_js_1.default.getFreePort(httpPort, 20, true);
|
|
@@ -191,4 +193,3 @@ function slateServer(httpPort, source, { homepage = '/index.html', enableWatch =
|
|
|
191
193
|
return new Promise((res) => server.on('listening', () => res(eventListener)));
|
|
192
194
|
});
|
|
193
195
|
}
|
|
194
|
-
exports.default = slateServer;
|
|
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.default = webClientServer;
|
|
15
16
|
const express_1 = __importDefault(require("express"));
|
|
16
17
|
const events_1 = require("events");
|
|
17
18
|
const chokidar_1 = require("chokidar");
|
|
@@ -24,13 +25,14 @@ const ws_1 = require("ws");
|
|
|
24
25
|
const port_resolver_js_1 = __importDefault(require("../../../../port-resolver.js"));
|
|
25
26
|
const ansi_colors_1 = require("ansi-colors");
|
|
26
27
|
const server_js_1 = require("../../../../util_modules/server.js");
|
|
28
|
+
const env_1 = require("../../../../util_modules/env");
|
|
27
29
|
function prepareScriptFile(dir, port) {
|
|
28
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29
31
|
const scriptFile = yield index_js_3.ASYNC.readFile(index_js_1.TEMPLATE.client.basic.socket);
|
|
30
32
|
if (!scriptFile) {
|
|
31
33
|
throw new index_js_2.default('Unable to read the script file', { exit: 2 });
|
|
32
34
|
}
|
|
33
|
-
const scriptReady = scriptFile.replace(new RegExp(index_js_1.PLACEHOLDER.client.
|
|
35
|
+
const scriptReady = scriptFile.replace(new RegExp(index_js_1.PLACEHOLDER.client.domain, 'g'), (0, env_1.getLocalAccessDomain)(port, 'ws'));
|
|
34
36
|
yield index_js_3.ASYNC.ensureDir(dir);
|
|
35
37
|
const scriptFilePath = (0, path_1.join)(dir, 'reload-script.js');
|
|
36
38
|
yield index_js_3.ASYNC.writeFile(scriptFilePath, scriptReady);
|
|
@@ -59,8 +61,8 @@ function reloadApp(event, path, liveSockets) {
|
|
|
59
61
|
(0, index_1.info)((0, ansi_colors_1.cyan)(`${event} detected in ${path} of the Web-Client.`));
|
|
60
62
|
liveSockets.forEach((socket) => socket.send('reload'));
|
|
61
63
|
}
|
|
62
|
-
function webClientServer(
|
|
63
|
-
return __awaiter(this,
|
|
64
|
+
function webClientServer(httpPort_1, source_1) {
|
|
65
|
+
return __awaiter(this, arguments, void 0, function* (httpPort, source, { homepage = 'index.html', enableWatch = true, notFoundPage } = {}) {
|
|
64
66
|
const eventListener = new events_1.EventEmitter();
|
|
65
67
|
const catalystTempDir = (0, path_1.join)(source, '.catalyst');
|
|
66
68
|
const socketServerPort = yield port_resolver_js_1.default.getFreePort(httpPort, 20, true);
|
|
@@ -191,4 +193,3 @@ function webClientServer(httpPort, source, { homepage = 'index.html', enableWatc
|
|
|
191
193
|
return new Promise((res) => server.on('listening', () => res(eventListener)));
|
|
192
194
|
});
|
|
193
195
|
}
|
|
194
|
-
exports.default = webClientServer;
|
|
@@ -41,8 +41,8 @@ const port_resolver_1 = __importDefault(require("../../port-resolver"));
|
|
|
41
41
|
const logUrl = (name, pthName, httpPort, masterPort) => {
|
|
42
42
|
(0, index_1.labeled)(`functions(${name})`, 'URL => http://localhost:' + (masterPort === -1 ? httpPort : masterPort) + pthName).MESSAGE();
|
|
43
43
|
};
|
|
44
|
-
const checkIfRuntimeServerRunning = (
|
|
45
|
-
if (itr >
|
|
44
|
+
const checkIfRuntimeServerRunning = (port_1, ...args_1) => __awaiter(void 0, [port_1, ...args_1], void 0, function* (port, itr = 0) {
|
|
45
|
+
if (itr > 100) {
|
|
46
46
|
throw new error_1.default('Unable to spin up python runtime server. Max retry reached', {
|
|
47
47
|
exit: 2
|
|
48
48
|
});
|
|
@@ -212,7 +212,7 @@ class HttpFunctions {
|
|
|
212
212
|
this.app.use(authenticator_1.default);
|
|
213
213
|
}
|
|
214
214
|
const reqHandler = (fnTarget) => (request, response, next) => {
|
|
215
|
-
var _a, _b, _c, _d;
|
|
215
|
+
var _a, _b, _c, _d, _e;
|
|
216
216
|
const urlParts = new url_1.URL(request.originalUrl, request.protocol + '://' + request.get('host')).searchParams;
|
|
217
217
|
const query = JSON.stringify(Object.fromEntries(urlParts.entries()));
|
|
218
218
|
const slaveOptions = [];
|
|
@@ -250,7 +250,7 @@ class HttpFunctions {
|
|
|
250
250
|
}));
|
|
251
251
|
slaveOptions.push(JSON.stringify((0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build)));
|
|
252
252
|
slave = this.q.push({
|
|
253
|
-
command: 'node',
|
|
253
|
+
command: ((_c = fnTarget.additionalInfo) === null || _c === void 0 ? void 0 : _c.binPath) || 'node',
|
|
254
254
|
options: slaveOptions,
|
|
255
255
|
pth: (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build, constants_1.FOLDERNAME.functions, fnTarget.name),
|
|
256
256
|
req: request,
|
|
@@ -259,7 +259,7 @@ class HttpFunctions {
|
|
|
259
259
|
envVars: fnTarget.env_var
|
|
260
260
|
});
|
|
261
261
|
}
|
|
262
|
-
else if ((
|
|
262
|
+
else if ((_d = fnTarget.stack) === null || _d === void 0 ? void 0 : _d.startsWith(runtime_1.default.language.java.value)) {
|
|
263
263
|
const invoker = fnTarget.type === constants_1.FN_TYPE.basic
|
|
264
264
|
? this.javaInvoker[fnTarget.type] + `/${fnTarget.stack}/JavabioInvoker`
|
|
265
265
|
: this.javaInvoker[fnTarget.type];
|
|
@@ -292,7 +292,7 @@ class HttpFunctions {
|
|
|
292
292
|
'x-zc-cookie': request.headers['x-zc-cookie'],
|
|
293
293
|
'x-zc-user-type': request.headers['x-zc-user-type']
|
|
294
294
|
}));
|
|
295
|
-
const spawnCommand = (0, ensure_java_userconfig_1.getJavaSpawnCommand)('java', (
|
|
295
|
+
const spawnCommand = (0, ensure_java_userconfig_1.getJavaSpawnCommand)('java', (_e = fnTarget.additionalInfo) === null || _e === void 0 ? void 0 : _e.binPath);
|
|
296
296
|
slave = this.q.push({
|
|
297
297
|
command: spawnCommand,
|
|
298
298
|
options: slaveOptions,
|
|
@@ -421,7 +421,7 @@ class HttpFunctions {
|
|
|
421
421
|
});
|
|
422
422
|
this.q.destroy(() => __awaiter(this, void 0, void 0, function* () {
|
|
423
423
|
var _a;
|
|
424
|
-
yield Promise.all(this.targets.map((target) => __awaiter(this, void 0, void 0, function* () { var
|
|
424
|
+
yield Promise.all(this.targets.map((target) => __awaiter(this, void 0, void 0, function* () { var _a; return (_a = target.watcher) === null || _a === void 0 ? void 0 : _a.close(); })));
|
|
425
425
|
yield ((_a = this.connDestroyer) === null || _a === void 0 ? void 0 : _a.destroy());
|
|
426
426
|
res();
|
|
427
427
|
}));
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -60,8 +70,8 @@ class FnExecutionHandler extends fn_handler_1.FnHandler {
|
|
|
60
70
|
super(serverDetails, localFnEvents);
|
|
61
71
|
}
|
|
62
72
|
execute(data, accessToken) {
|
|
63
|
-
var _a, _b, _c, _d, _e;
|
|
64
73
|
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
var _a, _b, _c, _d, _e;
|
|
65
75
|
const projectRoot = (0, project_1.getProjectRoot)();
|
|
66
76
|
const slaveFnTarget = {
|
|
67
77
|
index: (_b = (_a = this.fn.target) === null || _a === void 0 ? void 0 : _a.index) === null || _b === void 0 ? void 0 : _b.replace((0, path_1.join)(projectRoot, constants_1.FOLDERNAME.functions, this.fn.target.name) + path_1.sep, ''),
|
|
@@ -70,6 +80,7 @@ class FnExecutionHandler extends fn_handler_1.FnHandler {
|
|
|
70
80
|
switch (this.stack) {
|
|
71
81
|
case 'node': {
|
|
72
82
|
this.slave = (0, node_1.default)(this.fn, JSON.stringify(data), { slaveFnTarget, accessToken });
|
|
83
|
+
this.slave.once('spawn', () => utils_1.serverEvent.emit('connection'));
|
|
73
84
|
break;
|
|
74
85
|
}
|
|
75
86
|
case 'java': {
|
|
@@ -80,11 +91,10 @@ class FnExecutionHandler extends fn_handler_1.FnHandler {
|
|
|
80
91
|
slaveFnTarget,
|
|
81
92
|
accessToken
|
|
82
93
|
});
|
|
94
|
+
this.slave.once('spawn', () => utils_1.serverEvent.emit('connection'));
|
|
83
95
|
break;
|
|
84
96
|
}
|
|
85
97
|
case 'python': {
|
|
86
|
-
const pyFn = this.fn;
|
|
87
|
-
this.slave = yield (0, python_1.default)(pyFn);
|
|
88
98
|
const attachVsCodeDebugger = (port) => __awaiter(this, void 0, void 0, function* () {
|
|
89
99
|
try {
|
|
90
100
|
yield (0, server_1.isPortListening)(port, 25, env_1.isWindows ? 1000 : 500).catch((er) => (0, logger_1.debug)('error listening for port: ' + port, er));
|
|
@@ -103,27 +113,48 @@ class FnExecutionHandler extends fn_handler_1.FnHandler {
|
|
|
103
113
|
return;
|
|
104
114
|
}
|
|
105
115
|
});
|
|
116
|
+
const pyFn = this.fn;
|
|
117
|
+
const debugConfig = (_d = pyFn.target.additionalInfo) === null || _d === void 0 ? void 0 : _d.debug;
|
|
118
|
+
const httpPort = yield port_resolver_1.default.getFreePort(constants_1.DEFAULT.serve_port.http[(_e = this.fn.target) === null || _e === void 0 ? void 0 : _e.type], 200);
|
|
119
|
+
if (pyFn.target.type === 'job') {
|
|
120
|
+
const jobServer = yield this.processFlowHandler(data, httpPort);
|
|
121
|
+
this.slave = yield (0, python_1.default)(pyFn, httpPort);
|
|
122
|
+
if (!(this.slave instanceof child_process_1.ChildProcess)) {
|
|
123
|
+
jobServer.kill();
|
|
124
|
+
throw new error_1.default('Slave not an instance of Child process', {
|
|
125
|
+
context: this.slave,
|
|
126
|
+
exit: 2
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
this.slave.once('exit', () => jobServer.kill());
|
|
130
|
+
this.slave.once('error', () => jobServer.kill());
|
|
131
|
+
if (debugConfig && env_1.isExtension) {
|
|
132
|
+
yield new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
133
|
+
var _a, _b;
|
|
134
|
+
(_a = this.slave) === null || _a === void 0 ? void 0 : _a.once('spawn', () => {
|
|
135
|
+
resolve();
|
|
136
|
+
});
|
|
137
|
+
(_b = this.slave) === null || _b === void 0 ? void 0 : _b.once('error', (er) => {
|
|
138
|
+
reject(er);
|
|
139
|
+
});
|
|
140
|
+
}));
|
|
141
|
+
yield attachVsCodeDebugger(debugConfig.port);
|
|
142
|
+
}
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
this.slave = yield (0, python_1.default)(pyFn, httpPort);
|
|
106
146
|
if (!(this.slave instanceof child_process_1.ChildProcess)) {
|
|
107
147
|
throw new error_1.default('Slave not an instance of Child process', {
|
|
108
148
|
context: this.slave,
|
|
109
149
|
exit: 2
|
|
110
150
|
});
|
|
111
151
|
}
|
|
112
|
-
const debugConfig = (_d = pyFn.target.additionalInfo) === null || _d === void 0 ? void 0 : _d.debug;
|
|
113
|
-
if (this.fn.target.type === 'job') {
|
|
114
|
-
if (debugConfig && env_1.isVsCode) {
|
|
115
|
-
yield attachVsCodeDebugger(debugConfig.port);
|
|
116
|
-
}
|
|
117
|
-
const httpPort = yield port_resolver_1.default.getFreePort(constants_1.DEFAULT.serve_port.http[(_e = this.fn.target) === null || _e === void 0 ? void 0 : _e.type], 200);
|
|
118
|
-
this.processFlowHandler(data, httpPort);
|
|
119
|
-
break;
|
|
120
|
-
}
|
|
121
152
|
new Promise((resolve, reject) => {
|
|
122
153
|
var _a;
|
|
123
154
|
(_a = this.slave) === null || _a === void 0 ? void 0 : _a.once('spawn', () => __awaiter(this, void 0, void 0, function* () {
|
|
124
155
|
try {
|
|
125
156
|
if (debugConfig) {
|
|
126
|
-
if (env_1.
|
|
157
|
+
if (env_1.isExtension) {
|
|
127
158
|
yield attachVsCodeDebugger(debugConfig.port);
|
|
128
159
|
}
|
|
129
160
|
else {
|
|
@@ -177,8 +208,8 @@ class FnExecutionHandler extends fn_handler_1.FnHandler {
|
|
|
177
208
|
});
|
|
178
209
|
}
|
|
179
210
|
executeWithContainer(data, accessToken) {
|
|
180
|
-
var _a, _b, _c, _d, _e;
|
|
181
211
|
return __awaiter(this, void 0, void 0, function* () {
|
|
212
|
+
var _a, _b, _c, _d, _e;
|
|
182
213
|
(0, logger_1.debug)('using container to serve the function: ' + ((_a = this.fn.target) === null || _a === void 0 ? void 0 : _a.name));
|
|
183
214
|
const container = yield Promise.resolve().then(() => __importStar(require('@zcatalyst/container-plugin')));
|
|
184
215
|
const httpPort = yield port_resolver_1.default.getFreePort(constants_1.DEFAULT.serve_port.http[(_b = this.fn.target) === null || _b === void 0 ? void 0 : _b.type], 200);
|
|
@@ -222,13 +253,13 @@ class FnExecutionHandler extends fn_handler_1.FnHandler {
|
|
|
222
253
|
});
|
|
223
254
|
pluginEvent.emit('start', this.fn);
|
|
224
255
|
pluginEvent.once('ready', () => __awaiter(this, void 0, void 0, function* () {
|
|
225
|
-
var
|
|
256
|
+
var _a, _b;
|
|
226
257
|
try {
|
|
227
|
-
if (((
|
|
258
|
+
if (((_a = this.fn.target) === null || _a === void 0 ? void 0 : _a.type) === 'job') {
|
|
228
259
|
yield this.processFlowHandler(data, httpPort).finally(() => this.kill());
|
|
229
260
|
return;
|
|
230
261
|
}
|
|
231
|
-
if (((
|
|
262
|
+
if (((_b = this.fn.target) === null || _b === void 0 ? void 0 : _b.type) === 'cron') {
|
|
232
263
|
const cronData = {
|
|
233
264
|
project_details: {},
|
|
234
265
|
cron_details: {},
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
1
|
import EventEmitter from 'events';
|
|
4
2
|
import { IFnTarget } from '../../../fn-utils/lib/common';
|
|
5
3
|
import { IServerDetails } from '../../../serve/server';
|
|
@@ -18,7 +16,9 @@ export declare class FnHandler {
|
|
|
18
16
|
constructor(fn: IServerDetails<IFnTarget>, localFnEvents: EventEmitter);
|
|
19
17
|
writeResponse(response: string, status: number): void;
|
|
20
18
|
responseProcessor(statusCode: number, message?: string): void;
|
|
21
|
-
processFlowHandler(data: Record<string, unknown>, listenPort: number): Promise<
|
|
19
|
+
processFlowHandler(data: Record<string, unknown>, listenPort: number): Promise<{
|
|
20
|
+
kill: () => void;
|
|
21
|
+
}>;
|
|
22
22
|
fnRequestHandler({ httpPort, data, accessToken }: {
|
|
23
23
|
httpPort: number;
|
|
24
24
|
data?: Record<string, unknown>;
|
|
@@ -13,7 +13,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.FnHandler = void 0;
|
|
16
|
-
const child_process_1 = require("child_process");
|
|
17
16
|
const fs_1 = require("../../../util_modules/fs");
|
|
18
17
|
const constants_1 = require("../../../util_modules/constants");
|
|
19
18
|
const http_1 = require("http");
|
|
@@ -22,6 +21,7 @@ const server_1 = require("../../../util_modules/server");
|
|
|
22
21
|
const project_1 = require("../../../util_modules/project");
|
|
23
22
|
const error_1 = __importDefault(require("../../../error"));
|
|
24
23
|
const path_1 = require("path");
|
|
24
|
+
const utils_1 = require("@zcatalyst/container-plugin/out/utils");
|
|
25
25
|
class FnHandler {
|
|
26
26
|
constructor(fn, localFnEvents) {
|
|
27
27
|
this.closed = false;
|
|
@@ -81,10 +81,15 @@ class FnHandler {
|
|
|
81
81
|
processFlowHandler(data, listenPort) {
|
|
82
82
|
return __awaiter(this, void 0, void 0, function* () {
|
|
83
83
|
return new Promise((resolve, reject) => {
|
|
84
|
-
var _a;
|
|
85
84
|
const jobDetailsServer = new http_1.Server((serverReq, serverRes) => __awaiter(this, void 0, void 0, function* () {
|
|
86
|
-
var _b, _c;
|
|
87
|
-
|
|
85
|
+
var _a, _b, _c;
|
|
86
|
+
(0, logger_1.debug)(`[JOB_SERVER] [${serverReq.method}] ${serverReq.url}`);
|
|
87
|
+
if ((_a = serverReq.url) === null || _a === void 0 ? void 0 : _a.includes('/ruok')) {
|
|
88
|
+
serverRes.writeHead(200);
|
|
89
|
+
serverRes.write('Iam Ok!');
|
|
90
|
+
serverRes.end();
|
|
91
|
+
}
|
|
92
|
+
else if ((_b = serverReq.url) === null || _b === void 0 ? void 0 : _b.includes('data')) {
|
|
88
93
|
serverRes.writeHead(200);
|
|
89
94
|
serverRes.write(JSON.stringify({
|
|
90
95
|
data
|
|
@@ -101,29 +106,28 @@ class FnHandler {
|
|
|
101
106
|
serverRes.writeHead(200);
|
|
102
107
|
serverRes.write(JSON.stringify({}));
|
|
103
108
|
serverRes.end();
|
|
104
|
-
resolve();
|
|
105
|
-
return;
|
|
106
109
|
}
|
|
107
110
|
else {
|
|
108
111
|
(0, logger_1.debug)(`Invalid request: (${serverReq.method}) ${serverReq.url}`);
|
|
109
112
|
this.writeResponse('INTERNAL_SERVER_ERROR', 500);
|
|
110
113
|
reject(`Invalid request: (${serverReq.method}) ${serverReq.url}`);
|
|
111
|
-
return;
|
|
112
114
|
}
|
|
113
115
|
}));
|
|
114
116
|
const jobConnDestroyer = new server_1.ConnectionDestroyer(jobDetailsServer);
|
|
115
117
|
jobDetailsServer.listen(listenPort, '127.0.0.1', () => {
|
|
116
|
-
(0, logger_1.debug)('server listening on port :' + listenPort);
|
|
118
|
+
(0, logger_1.debug)('job server listening on port :' + listenPort);
|
|
119
|
+
resolve({
|
|
120
|
+
kill: () => {
|
|
121
|
+
jobConnDestroyer.destroy();
|
|
122
|
+
}
|
|
123
|
+
});
|
|
117
124
|
});
|
|
118
125
|
jobDetailsServer.on('error', reject);
|
|
119
|
-
(_a = this.slave) === null || _a === void 0 ? void 0 : _a.once('exit', () => {
|
|
120
|
-
jobConnDestroyer.destroy();
|
|
121
|
-
});
|
|
122
126
|
});
|
|
123
127
|
});
|
|
124
128
|
}
|
|
125
|
-
fnRequestHandler(
|
|
126
|
-
return __awaiter(this,
|
|
129
|
+
fnRequestHandler(_a) {
|
|
130
|
+
return __awaiter(this, arguments, void 0, function* ({ httpPort, data = {}, accessToken }) {
|
|
127
131
|
data.project_details = Object.assign({ id: (0, project_1.getProjectId)(), project_name: (0, project_1.getProjectName)() }, (data.project_details || {}));
|
|
128
132
|
const reqJson = JSON.stringify(data);
|
|
129
133
|
return new Promise((resolve, reject) => {
|
|
@@ -176,9 +180,10 @@ class FnHandler {
|
|
|
176
180
|
});
|
|
177
181
|
}
|
|
178
182
|
fnResponseHandler(code, sig) {
|
|
179
|
-
var _a, _b, _c, _d, _e;
|
|
180
183
|
return __awaiter(this, void 0, void 0, function* () {
|
|
184
|
+
var _a, _b, _c, _d, _e;
|
|
181
185
|
if (code === 0) {
|
|
186
|
+
(0, logger_1.info)();
|
|
182
187
|
(0, logger_1.info)(`[CLI] Function ${(_a = this.fn.target) === null || _a === void 0 ? void 0 : _a.name} execution complete`);
|
|
183
188
|
(0, logger_1.info)();
|
|
184
189
|
const response = yield fs_1.ASYNC.readFile(this.responseFile);
|
|
@@ -203,7 +208,9 @@ class FnHandler {
|
|
|
203
208
|
case constants_1.FN_TYPE.event:
|
|
204
209
|
(0, logger_1.info)(`[status - ${this.fn.target.name}] ${response || 'Unknown'}`);
|
|
205
210
|
if (!response) {
|
|
211
|
+
(0, logger_1.info)();
|
|
206
212
|
(0, logger_1.info)(`[CLI] Make sure to close the ${this.fn.target.name} (${this.fn.target.type}) function.`);
|
|
213
|
+
(0, logger_1.info)();
|
|
207
214
|
}
|
|
208
215
|
this.localFnEvents.emit('response', {
|
|
209
216
|
status: meta.statusCode
|
|
@@ -221,10 +228,16 @@ class FnHandler {
|
|
|
221
228
|
}
|
|
222
229
|
}
|
|
223
230
|
else {
|
|
224
|
-
(code === 130 || sig === 'SIGINT')
|
|
231
|
+
if (code === 130 || sig === 'SIGINT') {
|
|
232
|
+
(0, logger_1.info)();
|
|
225
233
|
(0, logger_1.info)(`[CLI] Function ${(_c = this.fn.target) === null || _c === void 0 ? void 0 : _c.name} interrupted`);
|
|
226
|
-
|
|
234
|
+
(0, logger_1.info)();
|
|
235
|
+
}
|
|
236
|
+
if (code === 143 || sig === 'SIGTERM' || sig === 'SIGQUIT' || sig === 'SIGKILL') {
|
|
237
|
+
(0, logger_1.info)();
|
|
227
238
|
(0, logger_1.info)(`[CLI] Function ${(_d = this.fn.target) === null || _d === void 0 ? void 0 : _d.name} process killed`);
|
|
239
|
+
(0, logger_1.info)();
|
|
240
|
+
}
|
|
228
241
|
this.localFnEvents.listenerCount('error') > 0 &&
|
|
229
242
|
this.localFnEvents.emit('error', new error_1.default(`Function(${(_e = this.fn.target) === null || _e === void 0 ? void 0 : _e.name}) process exited with ${code ? 'status: ' + code : 'signal: ' + sig}`, {
|
|
230
243
|
skipHelp: true
|
|
@@ -247,12 +260,33 @@ class FnHandler {
|
|
|
247
260
|
});
|
|
248
261
|
}
|
|
249
262
|
kill() {
|
|
250
|
-
|
|
263
|
+
var _a;
|
|
264
|
+
if (!this.slave || ((_a = this.slave) === null || _a === void 0 ? void 0 : _a.killed)) {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
(0, logger_1.info)();
|
|
268
|
+
(0, logger_1.info)('Terminating Function');
|
|
269
|
+
if (this.slave instanceof utils_1.ContainerEvents) {
|
|
270
|
+
this.slave.emit('close', this.fn);
|
|
251
271
|
return;
|
|
252
272
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
273
|
+
let isChildExited = false;
|
|
274
|
+
this.slave.kill('SIGTERM');
|
|
275
|
+
this.slave.once('exit', () => {
|
|
276
|
+
isChildExited = true;
|
|
277
|
+
});
|
|
278
|
+
setTimeout(() => {
|
|
279
|
+
if (!this.slave || this.slave instanceof utils_1.ContainerEvents) {
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
if (!isChildExited) {
|
|
283
|
+
(0, logger_1.debug)(`Emitting SIGKILL to PID: ${this.slave.pid}`);
|
|
284
|
+
this.slave.kill('SIGKILL');
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
(0, logger_1.debug)(`Fn child process kill confirmed PID: ${this.slave.pid}`);
|
|
288
|
+
}
|
|
289
|
+
}, 500);
|
|
256
290
|
}
|
|
257
291
|
}
|
|
258
292
|
exports.FnHandler = FnHandler;
|
|
@@ -5,7 +5,7 @@ const project_1 = require("../../../util_modules/project");
|
|
|
5
5
|
const constants_1 = require("../../../util_modules/constants");
|
|
6
6
|
const path_1 = require("path");
|
|
7
7
|
exports.default = (fn, data, { slaveFnTarget, accessToken }) => {
|
|
8
|
-
var _a, _b, _c, _d;
|
|
8
|
+
var _a, _b, _c, _d, _e, _f;
|
|
9
9
|
const slaveOptions = [];
|
|
10
10
|
const nodeInvoker = (0, path_1.normalize)((0, path_1.join)(__dirname, '../invoker', (_a = fn.target) === null || _a === void 0 ? void 0 : _a.type, 'node.mjs'));
|
|
11
11
|
if (fn.debugPort !== -1) {
|
|
@@ -28,9 +28,9 @@ exports.default = (fn, data, { slaveFnTarget, accessToken }) => {
|
|
|
28
28
|
'x-zc-user-type': 'admin'
|
|
29
29
|
}));
|
|
30
30
|
slaveOptions.push(JSON.stringify((0, path_1.join)((0, project_1.getProjectRoot)(), constants_1.FOLDERNAME.build)));
|
|
31
|
-
return (0, shell_1.spawn)('node', slaveOptions, {
|
|
32
|
-
cwd: (
|
|
31
|
+
return (0, shell_1.spawn)(((_c = (_b = fn.target) === null || _b === void 0 ? void 0 : _b.additionalInfo) === null || _c === void 0 ? void 0 : _c.binPath) || 'node', slaveOptions, {
|
|
32
|
+
cwd: (_d = fn.target) === null || _d === void 0 ? void 0 : _d.build,
|
|
33
33
|
stdio: 'pipe',
|
|
34
|
-
env: Object.assign({ X_ZOHO_CATALYST_IS_LOCAL: 'true', X_ZOHO_CATALYST_FUNCTION_LOADED: 'true', X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth, CATALYST_PORTAL_DOMAIN: constants_1.ORIGIN.iamPortal, X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin, X_ZOHO_CATALYST_RESOURCE_ID: (
|
|
34
|
+
env: Object.assign({ X_ZOHO_CATALYST_IS_LOCAL: 'true', X_ZOHO_CATALYST_FUNCTION_LOADED: 'true', X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth, CATALYST_PORTAL_DOMAIN: constants_1.ORIGIN.iamPortal, X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin, X_ZOHO_CATALYST_RESOURCE_ID: (_e = fn.target) === null || _e === void 0 ? void 0 : _e.id, X_ZOHO_STRATUS_RESOURCE_SUFFIX: constants_1.ORIGIN.stratusSuffix, CATALYST_PROJECT_TIMEZONE: (0, project_1.getProjectTimezone)(Intl.DateTimeFormat().resolvedOptions().timeZone) }, (_f = fn.target) === null || _f === void 0 ? void 0 : _f.env_var)
|
|
35
35
|
}).RAW();
|
|
36
36
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ChildProcess } from 'child_process';
|
|
2
2
|
import { IServerDetails } from '../../../serve/server';
|
|
3
3
|
import { IFnTarget, PythonFn } from '../../../fn-utils/lib/common';
|
|
4
|
-
declare const _default: (fn: IServerDetails<IFnTarget<PythonFn
|
|
4
|
+
declare const _default: (fn: IServerDetails<IFnTarget<PythonFn>>, runTimePort: number) => Promise<ChildProcess>;
|
|
5
5
|
export default _default;
|