underpost 2.8.884 → 2.8.885
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/README.md +4 -120
- package/bin/deploy.js +9 -10
- package/bin/file.js +4 -6
- package/cli.md +15 -11
- package/manifests/deployment/dd-default-development/deployment.yaml +2 -2
- package/manifests/deployment/dd-test-development/deployment.yaml +2 -2
- package/package.json +1 -1
- package/src/cli/cluster.js +21 -0
- package/src/cli/cron.js +8 -0
- package/src/cli/db.js +63 -1
- package/src/cli/deploy.js +156 -3
- package/src/cli/env.js +43 -0
- package/src/cli/fs.js +94 -0
- package/src/cli/image.js +8 -0
- package/src/cli/index.js +17 -4
- package/src/cli/monitor.js +0 -1
- package/src/cli/repository.js +95 -2
- package/src/client/components/core/Css.js +16 -0
- package/src/client/components/core/Docs.js +5 -13
- package/src/client/components/core/Modal.js +48 -29
- package/src/client/components/core/Router.js +6 -3
- package/src/client/components/core/Worker.js +205 -118
- package/src/client/components/default/MenuDefault.js +1 -0
- package/src/client.dev.js +6 -3
- package/src/db/DataBaseProvider.js +65 -12
- package/src/db/mariadb/MariaDB.js +39 -6
- package/src/db/mongo/MongooseDB.js +51 -133
- package/src/index.js +1 -1
- package/src/mailer/EmailRender.js +58 -9
- package/src/mailer/MailerProvider.js +98 -25
- package/src/runtime/express/Express.js +20 -34
- package/src/server/auth.js +9 -28
- package/src/server/client-build-live.js +14 -5
- package/src/server/client-dev-server.js +21 -8
- package/src/server/conf.js +78 -25
- package/src/server/peer.js +2 -2
- package/src/server/runtime.js +0 -5
- package/src/server/start.js +39 -0
- package/src/ws/IoInterface.js +132 -39
- package/src/ws/IoServer.js +79 -31
- package/src/ws/core/core.ws.connection.js +50 -16
- package/src/ws/core/core.ws.emit.js +47 -8
- package/src/ws/core/core.ws.server.js +62 -10
package/README.md
CHANGED
|
@@ -16,128 +16,12 @@
|
|
|
16
16
|
|
|
17
17
|
<div align="center">
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
19
|
<!-- badges -->
|
|
77
20
|
|
|
78
|
-
|
|
79
|
-
[](https://github.com/underpostnet/engine/actions/workflows/docker-image.yml) [](https://github.com/underpostnet/engine/actions/workflows/coverall.yml) [](https://www.npmjs.com/package/underpost) [](https://socket.dev/npm/package/underpost/overview/2.8.884) [](https://coveralls.io/github/underpostnet/engine?branch=master) [](https://www.npmjs.org/package/underpost) [](https://www.npmjs.com/package/underpost)
|
|
80
|
-
|
|
21
|
+
[](https://github.com/underpostnet/engine/actions/workflows/docker-image.yml) [](https://github.com/underpostnet/engine/actions/workflows/coverall.yml) [](https://www.npmjs.com/package/underpost) [](https://socket.dev/npm/package/underpost/overview/2.8.885) [](https://coveralls.io/github/underpostnet/engine?branch=master) [](https://www.npmjs.org/package/underpost) [](https://www.npmjs.com/package/underpost)
|
|
81
22
|
|
|
82
23
|
<!-- end-badges -->
|
|
83
24
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
25
|
</div>
|
|
142
26
|
|
|
143
27
|
<div align="center">
|
|
@@ -182,7 +66,7 @@ Run dev client server
|
|
|
182
66
|
npm run dev
|
|
183
67
|
```
|
|
184
68
|
<!-- -->
|
|
185
|
-
## underpost ci/cd cli v2.8.
|
|
69
|
+
## underpost ci/cd cli v2.8.885
|
|
186
70
|
|
|
187
71
|
### Usage: `underpost [options] [command]`
|
|
188
72
|
```
|
|
@@ -191,13 +75,13 @@ npm run dev
|
|
|
191
75
|
-h, --help display help for command
|
|
192
76
|
|
|
193
77
|
Commands:
|
|
194
|
-
new [options] <app-name> Initializes a new Underpost project
|
|
78
|
+
new [options] <app-name> Initializes a new Underpost project, service, or configuration.
|
|
195
79
|
start [options] <deploy-id> [env] Initiates application servers, build pipelines, or other defined services based on the deployment ID.
|
|
196
80
|
clone [options] <uri> Clones a specified GitHub repository into the current directory.
|
|
197
81
|
pull [options] <path> <uri> Pulls the latest changes from a specified GitHub repository.
|
|
198
82
|
cmt [options] <path> <commit-type> [module-tag] [message] Manages commits to a GitHub repository, supporting various commit types and options.
|
|
199
83
|
push [options] <path> <uri> Pushes committed changes from a local repository to a remote GitHub repository.
|
|
200
|
-
env
|
|
84
|
+
env [deploy-id] [env] [subConf] Sets environment variables and configurations related to a specific deployment ID.
|
|
201
85
|
config [options] <operator> [key] [value] Manages Underpost configurations using various operators.
|
|
202
86
|
root Displays the root path of the npm installation.
|
|
203
87
|
cluster [options] [pod-name] Manages Kubernetes clusters, defaulting to Kind cluster initialization.
|
package/bin/deploy.js
CHANGED
|
@@ -122,7 +122,12 @@ try {
|
|
|
122
122
|
}
|
|
123
123
|
break;
|
|
124
124
|
case 'conf': {
|
|
125
|
-
|
|
125
|
+
let subConf = process.argv[5] ?? '';
|
|
126
|
+
|
|
127
|
+
if (!['current', 'clean'].includes(process.argv[3]))
|
|
128
|
+
dotenv.config({ path: `./engine-private/conf/${process.argv[3]}/.env.${process.argv[4]}`, override: true });
|
|
129
|
+
|
|
130
|
+
loadConf(process.argv[3], subConf);
|
|
126
131
|
break;
|
|
127
132
|
}
|
|
128
133
|
|
|
@@ -194,10 +199,10 @@ try {
|
|
|
194
199
|
{
|
|
195
200
|
dotenv.config({ override: true });
|
|
196
201
|
if (!process.argv[3]) process.argv[3] = 'dd-default';
|
|
197
|
-
const { deployId
|
|
202
|
+
const { deployId } = loadConf(process.argv[3], process.argv[4] ?? '');
|
|
198
203
|
|
|
199
|
-
let argHost = process.argv[
|
|
200
|
-
let argPath = process.argv[
|
|
204
|
+
let argHost = process.argv[5] ? process.argv[5].split(',') : [];
|
|
205
|
+
let argPath = process.argv[6] ? process.argv[6].split(',') : [];
|
|
201
206
|
let deployIdSingleReplicas = [];
|
|
202
207
|
const serverConf = deployId
|
|
203
208
|
? JSON.parse(fs.readFileSync(`./conf/conf.server.json`, 'utf8'))
|
|
@@ -209,16 +214,10 @@ try {
|
|
|
209
214
|
} else {
|
|
210
215
|
serverConf[host][path].liteBuild = process.argv.includes('l') ? true : false;
|
|
211
216
|
serverConf[host][path].minifyBuild = process.env.NODE_ENV === 'production' ? true : false;
|
|
212
|
-
if (process.env.NODE_ENV === 'development' && process.argv.includes('static')) {
|
|
213
|
-
serverConf[host][path].apiBaseProxyPath = '/';
|
|
214
|
-
serverConf[host][path].apiBaseHost = `localhost:${parseInt(process.env.PORT) + 1}`;
|
|
215
|
-
}
|
|
216
217
|
if (serverConf[host][path].singleReplica && serverConf[host][path].replicas) {
|
|
217
218
|
deployIdSingleReplicas = deployIdSingleReplicas.concat(
|
|
218
219
|
serverConf[host][path].replicas.map((replica) => buildReplicaId({ deployId, replica })),
|
|
219
220
|
);
|
|
220
|
-
|
|
221
|
-
// shellExec(Cmd.replica(deployId, host, path));
|
|
222
221
|
}
|
|
223
222
|
}
|
|
224
223
|
}
|
package/bin/file.js
CHANGED
|
@@ -112,6 +112,8 @@ try {
|
|
|
112
112
|
`./.github/workflows/ghpkg.ci.yml`,
|
|
113
113
|
`./.github/workflows/publish.ci.yml`,
|
|
114
114
|
`./.github/workflows/release.cd.yml`,
|
|
115
|
+
'./src/ws/IoInterface.js',
|
|
116
|
+
'./src/ws/IoServer.js',
|
|
115
117
|
])
|
|
116
118
|
fs.copyFileSync(_path, `../pwa-microservices-template/${_path}`);
|
|
117
119
|
|
|
@@ -165,13 +167,9 @@ try {
|
|
|
165
167
|
|
|
166
168
|
originMd =
|
|
167
169
|
originMd.split(`<!-- badges -->`)[0] +
|
|
168
|
-
|
|
169
|
-
<!-- badges -->
|
|
170
|
-
` +
|
|
170
|
+
`<!-- badges -->` +
|
|
171
171
|
badges +
|
|
172
|
-
|
|
173
|
-
<!-- end-badges -->
|
|
174
|
-
` +
|
|
172
|
+
`<!-- end-badges -->` +
|
|
175
173
|
originMd.split(`<!-- end-badges -->`)[1];
|
|
176
174
|
|
|
177
175
|
const splitKeyword = '## underpost ci/cd cli';
|
package/cli.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
## underpost ci/cd cli v2.8.
|
|
1
|
+
## underpost ci/cd cli v2.8.885
|
|
2
2
|
|
|
3
3
|
### Usage: `underpost [options] [command]`
|
|
4
4
|
```
|
|
@@ -7,13 +7,13 @@
|
|
|
7
7
|
-h, --help display help for command
|
|
8
8
|
|
|
9
9
|
Commands:
|
|
10
|
-
new [options] <app-name> Initializes a new Underpost project
|
|
10
|
+
new [options] <app-name> Initializes a new Underpost project, service, or configuration.
|
|
11
11
|
start [options] <deploy-id> [env] Initiates application servers, build pipelines, or other defined services based on the deployment ID.
|
|
12
12
|
clone [options] <uri> Clones a specified GitHub repository into the current directory.
|
|
13
13
|
pull [options] <path> <uri> Pulls the latest changes from a specified GitHub repository.
|
|
14
14
|
cmt [options] <path> <commit-type> [module-tag] [message] Manages commits to a GitHub repository, supporting various commit types and options.
|
|
15
15
|
push [options] <path> <uri> Pushes committed changes from a local repository to a remote GitHub repository.
|
|
16
|
-
env
|
|
16
|
+
env [deploy-id] [env] [subConf] Sets environment variables and configurations related to a specific deployment ID.
|
|
17
17
|
config [options] <operator> [key] [value] Manages Underpost configurations using various operators.
|
|
18
18
|
root Displays the root path of the npm installation.
|
|
19
19
|
cluster [options] [pod-name] Manages Kubernetes clusters, defaulting to Kind cluster initialization.
|
|
@@ -44,16 +44,18 @@ Commands:
|
|
|
44
44
|
```
|
|
45
45
|
Usage: underpost new [options] <app-name>
|
|
46
46
|
|
|
47
|
-
Initializes a new Underpost project
|
|
47
|
+
Initializes a new Underpost project, service, or configuration.
|
|
48
48
|
|
|
49
49
|
Arguments:
|
|
50
|
-
app-name
|
|
50
|
+
app-name The name or deploy-id of the application to create.
|
|
51
51
|
|
|
52
52
|
Options:
|
|
53
|
-
--deploy-id
|
|
54
|
-
--cluster
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
--deploy-id Crete deploy ID conf env files
|
|
54
|
+
--cluster Create deploy ID cluster files and sync to current
|
|
55
|
+
cluster
|
|
56
|
+
--dev Sets the development cli context
|
|
57
|
+
--sub-conf <sub-conf> Create sub conf env files
|
|
58
|
+
-h, --help display help for command
|
|
57
59
|
|
|
58
60
|
```
|
|
59
61
|
|
|
@@ -157,16 +159,18 @@ Options:
|
|
|
157
159
|
|
|
158
160
|
### `env` :
|
|
159
161
|
```
|
|
160
|
-
Usage: underpost env [options]
|
|
162
|
+
Usage: underpost env [options] [deploy-id] [env] [subConf]
|
|
161
163
|
|
|
162
164
|
Sets environment variables and configurations related to a specific deployment
|
|
163
165
|
ID.
|
|
164
166
|
|
|
165
167
|
Arguments:
|
|
166
168
|
deploy-id The deployment configuration ID. Use 'clean' to restore default
|
|
167
|
-
environment settings.
|
|
169
|
+
environment settings. User 'root' to load root env. User
|
|
170
|
+
'current' to get plain current deploy Id.
|
|
168
171
|
env Optional: The environment to set (e.g., "production",
|
|
169
172
|
"development"). Defaults to "production".
|
|
173
|
+
subConf Optional: The sub configuration to set.
|
|
170
174
|
|
|
171
175
|
Options:
|
|
172
176
|
-h, --help display help for command
|
|
@@ -17,7 +17,7 @@ spec:
|
|
|
17
17
|
spec:
|
|
18
18
|
containers:
|
|
19
19
|
- name: dd-default-development-blue
|
|
20
|
-
image: localhost/rockylinux9-underpost:v2.8.
|
|
20
|
+
image: localhost/rockylinux9-underpost:v2.8.885
|
|
21
21
|
# resources:
|
|
22
22
|
# requests:
|
|
23
23
|
# memory: "124Ki"
|
|
@@ -100,7 +100,7 @@ spec:
|
|
|
100
100
|
spec:
|
|
101
101
|
containers:
|
|
102
102
|
- name: dd-default-development-green
|
|
103
|
-
image: localhost/rockylinux9-underpost:v2.8.
|
|
103
|
+
image: localhost/rockylinux9-underpost:v2.8.885
|
|
104
104
|
# resources:
|
|
105
105
|
# requests:
|
|
106
106
|
# memory: "124Ki"
|
|
@@ -17,7 +17,7 @@ spec:
|
|
|
17
17
|
spec:
|
|
18
18
|
containers:
|
|
19
19
|
- name: dd-test-development-blue
|
|
20
|
-
image: localhost/rockylinux9-underpost:v2.8.
|
|
20
|
+
image: localhost/rockylinux9-underpost:v2.8.885
|
|
21
21
|
# resources:
|
|
22
22
|
# requests:
|
|
23
23
|
# memory: "96294Ki"
|
|
@@ -104,7 +104,7 @@ spec:
|
|
|
104
104
|
spec:
|
|
105
105
|
containers:
|
|
106
106
|
- name: dd-test-development-green
|
|
107
|
-
image: localhost/rockylinux9-underpost:v2.8.
|
|
107
|
+
image: localhost/rockylinux9-underpost:v2.8.885
|
|
108
108
|
# resources:
|
|
109
109
|
# requests:
|
|
110
110
|
# memory: "96294Ki"
|
package/package.json
CHANGED
package/src/cli/cluster.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cluster module for managing Kubernetes cluster initialization, configuration, and component deployment.
|
|
3
|
+
* @module src/cli/cluster.js
|
|
4
|
+
* @namespace UnderpostCluster
|
|
5
|
+
*/
|
|
6
|
+
|
|
1
7
|
import { getNpmRootPath } from '../server/conf.js';
|
|
2
8
|
import { loggerFactory } from '../server/logger.js';
|
|
3
9
|
import { shellExec } from '../server/process.js';
|
|
@@ -45,6 +51,7 @@ class UnderpostCluster {
|
|
|
45
51
|
* @param {boolean} [options.config=false] - Apply general host configuration (SELinux, containerd, sysctl, firewalld).
|
|
46
52
|
* @param {boolean} [options.worker=false] - Configure as a worker node (for Kubeadm or K3s join).
|
|
47
53
|
* @param {boolean} [options.chown=false] - Set up kubectl configuration for the current user.
|
|
54
|
+
* @memberof UnderpostCluster
|
|
48
55
|
*/
|
|
49
56
|
async init(
|
|
50
57
|
podName,
|
|
@@ -460,6 +467,7 @@ EOF
|
|
|
460
467
|
* are applied for a healthy Kubernetes environment. It explicitly avoids
|
|
461
468
|
* iptables flushing commands to prevent conflicts with Kubernetes' own network management.
|
|
462
469
|
* @param {string} underpostRoot - The root directory of the underpost project.
|
|
470
|
+
* @memberof UnderpostCluster
|
|
463
471
|
*/
|
|
464
472
|
config(options = { underpostRoot: '.' }) {
|
|
465
473
|
const { underpostRoot } = options;
|
|
@@ -523,6 +531,7 @@ net.ipv4.ip_forward = 1' | sudo tee ${iptableConfPath}`,
|
|
|
523
531
|
* @method chown
|
|
524
532
|
* @description Sets up kubectl configuration for the current user based on the cluster type.
|
|
525
533
|
* @param {string} clusterType - The type of Kubernetes cluster ('kubeadm', 'k3s', or 'kind').
|
|
534
|
+
* @memberof UnderpostCluster
|
|
526
535
|
*/
|
|
527
536
|
chown(clusterType) {
|
|
528
537
|
console.log(`Setting up kubectl configuration for ${clusterType} cluster...`);
|
|
@@ -559,6 +568,7 @@ net.ipv4.ip_forward = 1' | sudo tee ${iptableConfPath}`,
|
|
|
559
568
|
* in coredns) by restoring SELinux security contexts and safely cleaning up cluster artifacts.
|
|
560
569
|
* @param {object} [options] - Configuration options for the reset.
|
|
561
570
|
* @param {string} [options.underpostRoot] - The root path of the underpost project.
|
|
571
|
+
* @memberof UnderpostCluster
|
|
562
572
|
*/
|
|
563
573
|
async safeReset(options = { underpostRoot: '.' }) {
|
|
564
574
|
logger.info('Starting a safe and comprehensive reset of Kubernetes and container environments...');
|
|
@@ -672,6 +682,13 @@ net.ipv4.ip_forward = 1' | sudo tee ${iptableConfPath}`,
|
|
|
672
682
|
}
|
|
673
683
|
},
|
|
674
684
|
|
|
685
|
+
/**
|
|
686
|
+
* @method getResourcesCapacity
|
|
687
|
+
* @description Retrieves the capacity of resources (CPU and memory) for a specific node in the cluster.
|
|
688
|
+
* @param {string} [node=os.hostname()] - The node to query. Defaults to the current host.
|
|
689
|
+
* @returns {object} An object containing the CPU and memory capacity of the node.
|
|
690
|
+
* @memberof UnderpostCluster
|
|
691
|
+
*/
|
|
675
692
|
getResourcesCapacity(node) {
|
|
676
693
|
const resources = {};
|
|
677
694
|
const nodeName = node ?? os.hostname();
|
|
@@ -698,9 +715,11 @@ net.ipv4.ip_forward = 1' | sudo tee ${iptableConfPath}`,
|
|
|
698
715
|
|
|
699
716
|
return resources;
|
|
700
717
|
},
|
|
718
|
+
|
|
701
719
|
/**
|
|
702
720
|
* @method initHost
|
|
703
721
|
* @description Installs essential host-level prerequisites for Kubernetes (Docker, Podman, Kind, Kubeadm, Helm).
|
|
722
|
+
* @memberof UnderpostCluster
|
|
704
723
|
*/
|
|
705
724
|
initHost() {
|
|
706
725
|
const archData = UnderpostBaremetal.API.getHostArch();
|
|
@@ -738,10 +757,12 @@ EOF`);
|
|
|
738
757
|
shellExec(`sudo rm -rf get_helm.sh`);
|
|
739
758
|
console.log('Host prerequisites installed successfully.');
|
|
740
759
|
},
|
|
760
|
+
|
|
741
761
|
/**
|
|
742
762
|
* @method uninstallHost
|
|
743
763
|
* @description Uninstalls all host components installed by initHost.
|
|
744
764
|
* This includes Docker, Podman, Kind, Kubeadm, Kubelet, Kubectl, and Helm.
|
|
765
|
+
* @memberof UnderpostCluster
|
|
745
766
|
*/
|
|
746
767
|
uninstallHost() {
|
|
747
768
|
console.log('Uninstalling host components: Docker, Podman, Kind, Kubeadm, Kubelet, Kubectl, Helm.');
|
package/src/cli/cron.js
CHANGED
|
@@ -71,6 +71,14 @@ class UnderpostCron {
|
|
|
71
71
|
if (UnderpostCron.JOB[jobId]) await UnderpostCron.JOB[jobId].callback(deployList, options);
|
|
72
72
|
}
|
|
73
73
|
},
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Get the related deploy id for the given job id
|
|
77
|
+
* @static
|
|
78
|
+
* @param {String} jobId - The job id
|
|
79
|
+
* @return {String} The related deploy id
|
|
80
|
+
* @memberof UnderpostCron
|
|
81
|
+
*/
|
|
74
82
|
getRelatedDeployId(jobId) {
|
|
75
83
|
switch (jobId) {
|
|
76
84
|
case 'dns':
|
package/src/cli/db.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UnderpostDB CLI index module
|
|
3
|
+
* @module src/cli/db.js
|
|
4
|
+
* @namespace UnderpostDB
|
|
5
|
+
*/
|
|
6
|
+
|
|
1
7
|
import { mergeFile, splitFileFactory } from '../server/conf.js';
|
|
2
8
|
import { loggerFactory } from '../server/logger.js';
|
|
3
9
|
import { shellExec } from '../server/process.js';
|
|
@@ -9,8 +15,36 @@ import { loadReplicas, pathPortAssignmentFactory } from '../server/conf.js';
|
|
|
9
15
|
|
|
10
16
|
const logger = loggerFactory(import.meta);
|
|
11
17
|
|
|
18
|
+
/**
|
|
19
|
+
* @class UnderpostDB
|
|
20
|
+
* @description Manages database operations and backups.
|
|
21
|
+
* This class provides a set of static methods to handle database operations,
|
|
22
|
+
* including importing and exporting data, managing database backups, and
|
|
23
|
+
* handling database connections for different providers (e.g., MariaDB, MongoDB).
|
|
24
|
+
* @memberof UnderpostDB
|
|
25
|
+
*/
|
|
12
26
|
class UnderpostDB {
|
|
13
27
|
static API = {
|
|
28
|
+
/**
|
|
29
|
+
* @method callback
|
|
30
|
+
* @description Initiates a database backup workflow based on the provided options.
|
|
31
|
+
* This method orchestrates the backup process for multiple deployments, handling
|
|
32
|
+
* database connections, backup storage, and optional Git integration for version control.
|
|
33
|
+
* @param {string} [deployList='default'] - List of deployment IDs to include in the backup.
|
|
34
|
+
* @param {object} [options] - An object containing boolean flags for various operations.
|
|
35
|
+
* @param {boolean} [options.import=false] - Flag to import data from a backup.
|
|
36
|
+
* @param {boolean} [options.export=false] - Flag to export data to a backup.
|
|
37
|
+
* @param {string} [options.podName=false] - The name of the Kubernetes pod to use for database operations.
|
|
38
|
+
* @param {string} [options.ns=false] - The namespace to use for database operations.
|
|
39
|
+
* @param {string} [options.collections=''] - Comma-separated list of collections to include in the backup.
|
|
40
|
+
* @param {string} [options.outPath=''] - Output path for the backup file.
|
|
41
|
+
* @param {boolean} [options.drop=false] - Flag to drop the database before importing.
|
|
42
|
+
* @param {boolean} [options.preserveUUID=false] - Flag to preserve UUIDs during import.
|
|
43
|
+
* @param {boolean} [options.git=false] - Flag to enable Git integration for version control.
|
|
44
|
+
* @param {string} [options.hosts=''] - Comma-separated list of hosts to include in the backup.
|
|
45
|
+
* @param {string} [options.paths=''] - Comma-separated list of paths to include in the backup.
|
|
46
|
+
* @memberof UnderpostDB
|
|
47
|
+
*/
|
|
14
48
|
async callback(
|
|
15
49
|
deployList = 'default',
|
|
16
50
|
options = {
|
|
@@ -200,6 +234,17 @@ class UnderpostDB {
|
|
|
200
234
|
}
|
|
201
235
|
}
|
|
202
236
|
},
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* @method clusterMetadataFactory
|
|
240
|
+
* @description Creates a cluster metadata object for the specified deployment.
|
|
241
|
+
* This method loads database configuration and initializes a cluster metadata object
|
|
242
|
+
* using the provided deployment ID, host, and path.
|
|
243
|
+
* @param {string} [deployId=process.env.DEFAULT_DEPLOY_ID] - The deployment ID to use.
|
|
244
|
+
* @param {string} [host=process.env.DEFAULT_DEPLOY_HOST] - The host to use.
|
|
245
|
+
* @param {string} [path=process.env.DEFAULT_DEPLOY_PATH] - The path to use.
|
|
246
|
+
* @memberof UnderpostDB
|
|
247
|
+
*/
|
|
203
248
|
async clusterMetadataFactory(
|
|
204
249
|
deployId = process.env.DEFAULT_DEPLOY_ID,
|
|
205
250
|
host = process.env.DEFAULT_DEPLOY_HOST,
|
|
@@ -227,7 +272,6 @@ class UnderpostDB {
|
|
|
227
272
|
if (!deployId) continue;
|
|
228
273
|
const confServer = loadReplicas(
|
|
229
274
|
JSON.parse(fs.readFileSync(`./engine-private/conf/${deployId}/conf.server.json`, 'utf8')),
|
|
230
|
-
'proxy',
|
|
231
275
|
);
|
|
232
276
|
const router = await UnderpostDeploy.API.routerFactory(deployId, env);
|
|
233
277
|
const pathPortAssignmentData = pathPortAssignmentFactory(router, confServer);
|
|
@@ -298,6 +342,24 @@ class UnderpostDB {
|
|
|
298
342
|
}
|
|
299
343
|
await DataBaseProvider.instance[`${host}${path}`].mongoose.close();
|
|
300
344
|
},
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* @method clusterMetadataBackupCallback
|
|
348
|
+
* @description Handles the backup of cluster metadata for the specified deployment.
|
|
349
|
+
* This method orchestrates the backup process for cluster metadata, including
|
|
350
|
+
* instances and crons, and handles optional Git integration for version control.
|
|
351
|
+
* @param {string} [deployId=process.env.DEFAULT_DEPLOY_ID] - The deployment ID to use.
|
|
352
|
+
* @param {string} [host=process.env.DEFAULT_DEPLOY_HOST] - The host to use.
|
|
353
|
+
* @param {string} [path=process.env.DEFAULT_DEPLOY_PATH] - The path to use.
|
|
354
|
+
* @param {object} [options] - An object containing boolean flags for various operations.
|
|
355
|
+
* @param {boolean} [options.generate=false] - Flag to generate cluster metadata.
|
|
356
|
+
* @param {boolean} [options.itc=false] - Flag to enable Git integration for version control.
|
|
357
|
+
* @param {boolean} [options.import=false] - Flag to import data from a backup.
|
|
358
|
+
* @param {boolean} [options.export=false] - Flag to export data to a backup.
|
|
359
|
+
* @param {boolean} [options.instances=false] - Flag to backup instances.
|
|
360
|
+
* @param {boolean} [options.crons=false] - Flag to backup crons.
|
|
361
|
+
* @memberof UnderpostDB
|
|
362
|
+
*/
|
|
301
363
|
clusterMetadataBackupCallback(
|
|
302
364
|
deployId = process.env.DEFAULT_DEPLOY_ID,
|
|
303
365
|
host = process.env.DEFAULT_DEPLOY_HOST,
|