biz-a-cli 2.3.73 → 2.3.74

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.
@@ -1,18 +1,71 @@
1
- import workerpool from 'workerpool';
1
+ import workerpool from "workerpool";
2
2
 
3
3
  export const cliScriptWorkerPool = workerpool.pool(
4
- "./worker/cliScriptWorker.js",
5
- {
6
- workerType: 'thread',
7
- emitStdStreams: true, // the worker will emit stdout and stderr events instead of passing it through to the parent streams
8
- workerThreadOpts: {env: {NODE_ENV: process.env.NODE_ENV || 'production'}}
9
- });
4
+ "./worker/cliScriptWorker.js",
5
+ {
6
+ workerType: "thread",
7
+ emitStdStreams: true, // the worker will emit stdout and stderr events instead of passing it through to the parent streams
8
+ workerThreadOpts: {
9
+ env: { NODE_ENV: process.env.NODE_ENV || "production" },
10
+ },
11
+ },
12
+ );
10
13
 
11
- export const execCLIScriptWorker = async (apiConfig, scriptName, scriptData)=>cliScriptWorkerPool.exec('run', [apiConfig, scriptName, scriptData]);
14
+ export const execCLIScriptWorker = async (
15
+ apiConfig,
16
+ scriptName,
17
+ scriptData,
18
+ ) => {
19
+ // callback
20
+ // {
21
+ // arguments: args,
22
+ // body: req.body.body,
23
+ // path: req.path,
24
+ // query: req.body.query,
25
+ // headers: req.body.headers,
26
+ // },
12
27
 
13
- export const workerStats = ()=>{return {cliScript: cliScriptWorkerPool.stats()}};
28
+ // watcher
29
+ // const urlAndPort = config.url.split(":");
30
+ // {
31
+ // arguments: {
32
+ // hostname: urlAndPort[1].split("//")[1],
33
+ // port: +urlAndPort[2],
34
+ // dbindex: config.dbindex,
35
+ // finaDbIndex: config.finaDbIndex,
36
+ // subdomain: config.subdomain,
37
+ // smtp: config.smtp,
38
+ // },
39
+ // body: trigger.data ?? null,
40
+ // };
41
+
42
+ // live Trigger
43
+ // {
44
+ // arguments: argv,
45
+ // body: data.scriptData ?? null,
46
+ // path: "/live-trigger",
47
+ // query: { scriptName: data.scriptName },
48
+ // headers: { "user-agent": "biz-a-client-socket" },
49
+ // };
50
+
51
+ // Worker threads can only accept strings, numbers, booleans, and pure JSON objects/arrays.
52
+ // It cannot serialize live functions, object or DOM nodes
53
+ const safeData = JSON.parse(JSON.stringify(scriptData));
54
+ return cliScriptWorkerPool.exec("run", [apiConfig, scriptName, safeData]);
55
+ };
56
+
57
+ export const workerStats = () => {
58
+ return { cliScript: cliScriptWorkerPool.stats() };
59
+ };
14
60
 
15
61
  // note: if process.exit is explicitly executed by internal code, then
16
62
  // ensure to manually call workerpool.terminate() if available
17
63
  // ortherwise ensure Operating system clean up worker when main thread terminated
18
- process.on('beforeexit', async ()=>{await cliScriptWorkerPool.terminate()});
64
+ async function cliWorkerPoolBeforeExitHandler() {
65
+ await cliScriptWorkerPool.terminate();
66
+ }
67
+
68
+ if (!process.__cliWorkerPoolBeforeExitAttached) {
69
+ process.on("beforeexit", cliWorkerPoolBeforeExitHandler);
70
+ process.__cliWorkerPoolBeforeExitAttached = true;
71
+ }
package/.editorconfig DELETED
@@ -1,16 +0,0 @@
1
- # Editor configuration, see https://editorconfig.org
2
- root = true
3
-
4
- [*]
5
- charset = utf-8
6
- indent_style = tab
7
- tab_width = 4
8
- insert_final_newline = true
9
- trim_trailing_whitespace = true
10
-
11
- [*.ts]
12
- quote_type = single
13
-
14
- [*.md]
15
- max_line_length = off
16
- trim_trailing_whitespace = false
package/log/debug.log DELETED
File without changes
package/log/error.log DELETED
File without changes
package/log/exception.log DELETED
File without changes
package/log/info.log DELETED
File without changes