underpost 2.8.861 → 2.8.866
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/.env.development +6 -1
- package/.env.production +6 -1
- package/.env.test +6 -1
- package/README.md +40 -36
- package/bin/deploy.js +7 -32
- package/cli.md +93 -90
- package/conf.js +1 -1
- package/manifests/deployment/dd-default-development/deployment.yaml +2 -2
- package/package.json +2 -2
- package/src/cli/cluster.js +2 -10
- package/src/cli/deploy.js +4 -3
- package/src/cli/index.js +3 -1
- package/src/cli/repository.js +4 -2
- package/src/cli/run.js +8 -0
- package/src/index.js +1 -1
- package/src/server/client-build.js +1 -7
- package/src/server/conf.js +69 -78
- package/src/server/proxy.js +1 -1
- package/src/server/runtime.js +1 -2
- package/src/server/start.js +2 -2
package/.env.development
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
DEPLOY_ID=dd-default
|
|
2
|
+
DEFAULT_DEPLOY_ID=dd-default
|
|
2
3
|
NODE_ENV=development
|
|
3
4
|
PORT=4000
|
|
4
5
|
JWT_SECRET=test
|
|
5
6
|
EXPIRE=168
|
|
6
7
|
NODE_OPTIONS=--max-old-space-size=8192
|
|
7
|
-
BASE_API=api
|
|
8
|
+
BASE_API=api
|
|
9
|
+
DEFAULT_DEPLOY_HOST=default.net
|
|
10
|
+
DEFAULT_DEPLOY_PATH=/
|
|
11
|
+
DEFAULT_ADMIN_EMAIL=admin@default.net
|
|
12
|
+
DEFAULT_ADMIN_PASSWORD=changethis
|
package/.env.production
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
DEPLOY_ID=dd-default
|
|
2
|
+
DEFAULT_DEPLOY_ID=dd-default
|
|
2
3
|
NODE_ENV=production
|
|
3
4
|
PORT=3000
|
|
4
5
|
JWT_SECRET=test
|
|
5
6
|
EXPIRE=168
|
|
6
7
|
NODE_OPTIONS=--max-old-space-size=8192
|
|
7
|
-
BASE_API=api
|
|
8
|
+
BASE_API=api
|
|
9
|
+
DEFAULT_DEPLOY_HOST=default.net
|
|
10
|
+
DEFAULT_DEPLOY_PATH=/
|
|
11
|
+
DEFAULT_ADMIN_EMAIL=admin@default.net
|
|
12
|
+
DEFAULT_ADMIN_PASSWORD=changethis
|
package/.env.test
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
DEPLOY_ID=dd-default
|
|
2
|
+
DEFAULT_DEPLOY_ID=dd-default
|
|
2
3
|
NODE_ENV=test
|
|
3
4
|
PORT=5000
|
|
4
5
|
JWT_SECRET=test
|
|
5
6
|
EXPIRE=168
|
|
6
7
|
NODE_OPTIONS=--max-old-space-size=8192
|
|
7
|
-
BASE_API=api
|
|
8
|
+
BASE_API=api
|
|
9
|
+
DEFAULT_DEPLOY_HOST=default.net
|
|
10
|
+
DEFAULT_DEPLOY_PATH=/
|
|
11
|
+
DEFAULT_ADMIN_EMAIL=admin@default.net
|
|
12
|
+
DEFAULT_ADMIN_PASSWORD=changethis
|
package/README.md
CHANGED
|
@@ -27,10 +27,12 @@
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
|
30
|
+
|
|
31
|
+
|
|
30
32
|
<!-- badges -->
|
|
31
33
|
|
|
32
34
|
|
|
33
|
-
[](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://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.866) [](https://coveralls.io/github/underpostnet/engine?branch=master) [](https://www.npmjs.org/package/underpost) [](https://www.npmjs.com/package/underpost)
|
|
34
36
|
|
|
35
37
|
|
|
36
38
|
<!-- end-badges -->
|
|
@@ -46,6 +48,8 @@
|
|
|
46
48
|
|
|
47
49
|
|
|
48
50
|
|
|
51
|
+
|
|
52
|
+
|
|
49
53
|
</div>
|
|
50
54
|
|
|
51
55
|
<div align="center">
|
|
@@ -90,44 +94,44 @@ Run dev client server
|
|
|
90
94
|
npm run dev
|
|
91
95
|
```
|
|
92
96
|
<!-- -->
|
|
93
|
-
## underpost ci/cd cli v2.8.
|
|
97
|
+
## underpost ci/cd cli v2.8.866
|
|
94
98
|
|
|
95
99
|
### Usage: `underpost [options] [command]`
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
-
|
|
100
|
-
-h, --help display help for command
|
|
100
|
+
```
|
|
101
|
+
Options:
|
|
102
|
+
-V, --version output the version number
|
|
103
|
+
-h, --help display help for command
|
|
101
104
|
|
|
102
105
|
Commands:
|
|
103
|
-
new [options] <app-name> Initializes a new Underpost project with a predefined structure.
|
|
104
|
-
start [options] <deploy-id> [env] Initiates application servers, build pipelines, or other defined services based on the deployment ID.
|
|
105
|
-
clone [options] <uri> Clones a specified GitHub repository into the current directory.
|
|
106
|
-
pull [options] <path> <uri> Pulls the latest changes from a specified GitHub repository.
|
|
107
|
-
cmt [options] <path> <commit-type> [module-tag] [message] Manages commits to a GitHub repository, supporting various commit types and options.
|
|
108
|
-
push [options] <path> <uri> Pushes committed changes from a local repository to a remote GitHub repository.
|
|
109
|
-
env <deploy-id> [env] Sets environment variables and configurations related to a specific deployment ID.
|
|
110
|
-
config [options] <operator> [key] [value] Manages Underpost configurations using various operators.
|
|
111
|
-
root Displays the root path of the npm installation.
|
|
112
|
-
cluster [options] [pod-name] Manages Kubernetes clusters, defaulting to Kind cluster initialization.
|
|
113
|
-
deploy [options] [deploy-list] [env] Manages application deployments, defaulting to deploying development pods.
|
|
114
|
-
secret [options] <platform> Manages secrets for various platforms.
|
|
115
|
-
dockerfile-image-build [options] Builds a Docker image from a specified Dockerfile with various options for naming, saving, and loading.
|
|
116
|
-
dockerfile-pull-base-images [options] Pulls required Underpost Dockerfile base images and optionally loads them into clusters.
|
|
117
|
-
install Quickly imports Underpost npm dependencies by copying them.
|
|
118
|
-
db [options] <deploy-list> Manages database operations, including import, export, and collection management.
|
|
119
|
-
metadata [options] [deploy-id] [host] [path] Manages cluster metadata operations, including import and export.
|
|
120
|
-
script [options] <operator> <script-name> [script-value] Supports a variety of built-in Underpost global scripts, their preset lifecycle events, and arbitrary custom scripts.
|
|
121
|
-
cron [options] [deploy-list] [job-list] Manages cron jobs, including initialization, execution, and configuration updates.
|
|
122
|
-
fs [options] [path] Manages file storage, defaulting to file upload operations.
|
|
123
|
-
test [options] [deploy-list] Manages and runs tests, defaulting to the current Underpost default test suite.
|
|
124
|
-
monitor [options] <deploy-id> [env] Manages health server monitoring for specified deployments.
|
|
125
|
-
ssh [options] Import and start ssh server and client based on current default deployment ID.
|
|
126
|
-
run [options] <runner-id> [path] Runs a script from the specified path.
|
|
127
|
-
lxd [options] Manages LXD containers and virtual machines.
|
|
128
|
-
baremetal [options] [workflow-id] [hostname] [ip-address] Manages baremetal server operations, including installation, database setup, commissioning, and user management.
|
|
129
|
-
help [command] display help for command
|
|
130
|
-
|
|
106
|
+
new [options] <app-name> Initializes a new Underpost project with a predefined structure.
|
|
107
|
+
start [options] <deploy-id> [env] Initiates application servers, build pipelines, or other defined services based on the deployment ID.
|
|
108
|
+
clone [options] <uri> Clones a specified GitHub repository into the current directory.
|
|
109
|
+
pull [options] <path> <uri> Pulls the latest changes from a specified GitHub repository.
|
|
110
|
+
cmt [options] <path> <commit-type> [module-tag] [message] Manages commits to a GitHub repository, supporting various commit types and options.
|
|
111
|
+
push [options] <path> <uri> Pushes committed changes from a local repository to a remote GitHub repository.
|
|
112
|
+
env <deploy-id> [env] Sets environment variables and configurations related to a specific deployment ID.
|
|
113
|
+
config [options] <operator> [key] [value] Manages Underpost configurations using various operators.
|
|
114
|
+
root Displays the root path of the npm installation.
|
|
115
|
+
cluster [options] [pod-name] Manages Kubernetes clusters, defaulting to Kind cluster initialization.
|
|
116
|
+
deploy [options] [deploy-list] [env] Manages application deployments, defaulting to deploying development pods.
|
|
117
|
+
secret [options] <platform> Manages secrets for various platforms.
|
|
118
|
+
dockerfile-image-build [options] Builds a Docker image from a specified Dockerfile with various options for naming, saving, and loading.
|
|
119
|
+
dockerfile-pull-base-images [options] Pulls required Underpost Dockerfile base images and optionally loads them into clusters.
|
|
120
|
+
install Quickly imports Underpost npm dependencies by copying them.
|
|
121
|
+
db [options] <deploy-list> Manages database operations, including import, export, and collection management.
|
|
122
|
+
metadata [options] [deploy-id] [host] [path] Manages cluster metadata operations, including import and export.
|
|
123
|
+
script [options] <operator> <script-name> [script-value] Supports a variety of built-in Underpost global scripts, their preset lifecycle events, and arbitrary custom scripts.
|
|
124
|
+
cron [options] [deploy-list] [job-list] Manages cron jobs, including initialization, execution, and configuration updates.
|
|
125
|
+
fs [options] [path] Manages file storage, defaulting to file upload operations.
|
|
126
|
+
test [options] [deploy-list] Manages and runs tests, defaulting to the current Underpost default test suite.
|
|
127
|
+
monitor [options] <deploy-id> [env] Manages health server monitoring for specified deployments.
|
|
128
|
+
ssh [options] Import and start ssh server and client based on current default deployment ID.
|
|
129
|
+
run [options] <runner-id> [path] Runs a script from the specified path.
|
|
130
|
+
lxd [options] Manages LXD containers and virtual machines.
|
|
131
|
+
baremetal [options] [workflow-id] [hostname] [ip-address] Manages baremetal server operations, including installation, database setup, commissioning, and user management.
|
|
132
|
+
help [command] display help for command
|
|
133
|
+
|
|
131
134
|
```
|
|
132
|
-
|
|
135
|
+
|
|
133
136
|
<a target="_top" href="https://github.com/underpostnet/pwa-microservices-template/blob/master/cli.md">See complete CLI Docs here.</a>
|
|
137
|
+
|
package/bin/deploy.js
CHANGED
|
@@ -39,31 +39,6 @@ const [exe, dir, operator] = process.argv;
|
|
|
39
39
|
|
|
40
40
|
try {
|
|
41
41
|
switch (operator) {
|
|
42
|
-
case 'save':
|
|
43
|
-
{
|
|
44
|
-
let deployId = process.argv[3] ?? 'dd-default';
|
|
45
|
-
if (!deployId.startsWith('dd-')) deployId = 'dd-default';
|
|
46
|
-
const folder = `./engine-private/conf/${deployId}`;
|
|
47
|
-
if (fs.existsSync(folder)) fs.removeSync(folder);
|
|
48
|
-
await Config.build({ folder });
|
|
49
|
-
fs.writeFileSync(
|
|
50
|
-
`${folder}/.env.production`,
|
|
51
|
-
fs.readFileSync('./.env.production', 'utf8').replace('dd-default', deployId),
|
|
52
|
-
'utf8',
|
|
53
|
-
);
|
|
54
|
-
fs.writeFileSync(
|
|
55
|
-
`${folder}/.env.development`,
|
|
56
|
-
fs.readFileSync('./.env.development', 'utf8').replace('dd-default', deployId),
|
|
57
|
-
'utf8',
|
|
58
|
-
);
|
|
59
|
-
fs.writeFileSync(
|
|
60
|
-
`${folder}/.env.test`,
|
|
61
|
-
fs.readFileSync('./.env.test', 'utf8').replace('dd-default', deployId),
|
|
62
|
-
'utf8',
|
|
63
|
-
);
|
|
64
|
-
fs.writeFileSync(`${folder}/package.json`, fs.readFileSync('./package.json', 'utf8'), 'utf8');
|
|
65
|
-
}
|
|
66
|
-
break;
|
|
67
42
|
case 'add-nodejs-app-client-conf':
|
|
68
43
|
{
|
|
69
44
|
const toOptions = {
|
|
@@ -283,23 +258,20 @@ try {
|
|
|
283
258
|
for (const deployIdObj of dataDeploy) {
|
|
284
259
|
const { deployId, replicaHost } = deployIdObj;
|
|
285
260
|
if (replicaHost && !singleReplicaHosts.includes(replicaHost)) singleReplicaHosts.push(replicaHost);
|
|
286
|
-
const proxyInstance = deployId.match('proxy') || deployId.match('cron');
|
|
287
261
|
const baseConfPath = fs.existsSync(`./engine-private/replica/${deployId}`)
|
|
288
262
|
? `./engine-private/replica`
|
|
289
263
|
: `./engine-private/conf`;
|
|
290
264
|
for (const envInstanceObj of dataEnv) {
|
|
291
265
|
const envPath = `${baseConfPath}/${deployId}/.env.${envInstanceObj.env}`;
|
|
292
266
|
const envObj = dotenv.parse(fs.readFileSync(envPath, 'utf8'));
|
|
293
|
-
envObj.PORT =
|
|
294
|
-
? envInstanceObj.port
|
|
295
|
-
: envInstanceObj.port + port - singleReplicaHosts.length - (replicaHost ? 1 : 0);
|
|
267
|
+
envObj.PORT = envInstanceObj.port + port - singleReplicaHosts.length - (replicaHost ? 1 : 0);
|
|
296
268
|
|
|
297
269
|
writeEnv(envPath, envObj);
|
|
298
270
|
}
|
|
299
271
|
const serverConf = loadReplicas(
|
|
300
272
|
JSON.parse(fs.readFileSync(`${baseConfPath}/${deployId}/conf.server.json`, 'utf8')),
|
|
301
273
|
);
|
|
302
|
-
|
|
274
|
+
for (const host of Object.keys(serverConf)) port += Object.keys(serverConf[host]).length;
|
|
303
275
|
}
|
|
304
276
|
break;
|
|
305
277
|
|
|
@@ -399,6 +371,7 @@ try {
|
|
|
399
371
|
shellCd(`/home/dd/engine`);
|
|
400
372
|
const originPackageJson = JSON.parse(fs.readFileSync(`package.json`, 'utf8'));
|
|
401
373
|
const newVersion = process.argv[3] ?? originPackageJson.version;
|
|
374
|
+
const node = process.argv[4] ?? 'kind-control-plane';
|
|
402
375
|
const { version } = originPackageJson;
|
|
403
376
|
originPackageJson.version = newVersion;
|
|
404
377
|
fs.writeFileSync(`package.json`, JSON.stringify(originPackageJson, null, 4), 'utf8');
|
|
@@ -456,8 +429,10 @@ try {
|
|
|
456
429
|
shellExec(`node bin/deploy update-dependencies`);
|
|
457
430
|
shellExec(`auto-changelog`);
|
|
458
431
|
shellExec(`node bin/build dd`);
|
|
459
|
-
shellExec(`node bin deploy --kubeadm --build-manifest --sync --info-router --replicas 1 dd`);
|
|
460
|
-
shellExec(
|
|
432
|
+
shellExec(`node bin deploy --kubeadm --build-manifest --sync --info-router --replicas 1 --node ${node} dd`);
|
|
433
|
+
shellExec(
|
|
434
|
+
`node bin deploy --kubeadm --build-manifest --sync --info-router --replicas 1 --node ${node} dd production`,
|
|
435
|
+
);
|
|
461
436
|
break;
|
|
462
437
|
}
|
|
463
438
|
|
package/cli.md
CHANGED
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
## underpost ci/cd cli v2.8.
|
|
1
|
+
## underpost ci/cd cli v2.8.866
|
|
2
2
|
|
|
3
3
|
### Usage: `underpost [options] [command]`
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
-h, --help display help for command
|
|
4
|
+
```
|
|
5
|
+
Options:
|
|
6
|
+
-V, --version output the version number
|
|
7
|
+
-h, --help display help for command
|
|
9
8
|
|
|
10
9
|
Commands:
|
|
11
|
-
new [options] <app-name> Initializes a new Underpost project with a predefined structure.
|
|
12
|
-
start [options] <deploy-id> [env] Initiates application servers, build pipelines, or other defined services based on the deployment ID.
|
|
13
|
-
clone [options] <uri> Clones a specified GitHub repository into the current directory.
|
|
14
|
-
pull [options] <path> <uri> Pulls the latest changes from a specified GitHub repository.
|
|
15
|
-
cmt [options] <path> <commit-type> [module-tag] [message] Manages commits to a GitHub repository, supporting various commit types and options.
|
|
16
|
-
push [options] <path> <uri> Pushes committed changes from a local repository to a remote GitHub repository.
|
|
17
|
-
env <deploy-id> [env] Sets environment variables and configurations related to a specific deployment ID.
|
|
18
|
-
config [options] <operator> [key] [value] Manages Underpost configurations using various operators.
|
|
19
|
-
root Displays the root path of the npm installation.
|
|
20
|
-
cluster [options] [pod-name] Manages Kubernetes clusters, defaulting to Kind cluster initialization.
|
|
21
|
-
deploy [options] [deploy-list] [env] Manages application deployments, defaulting to deploying development pods.
|
|
22
|
-
secret [options] <platform> Manages secrets for various platforms.
|
|
23
|
-
dockerfile-image-build [options] Builds a Docker image from a specified Dockerfile with various options for naming, saving, and loading.
|
|
24
|
-
dockerfile-pull-base-images [options] Pulls required Underpost Dockerfile base images and optionally loads them into clusters.
|
|
25
|
-
install Quickly imports Underpost npm dependencies by copying them.
|
|
26
|
-
db [options] <deploy-list> Manages database operations, including import, export, and collection management.
|
|
27
|
-
metadata [options] [deploy-id] [host] [path] Manages cluster metadata operations, including import and export.
|
|
28
|
-
script [options] <operator> <script-name> [script-value] Supports a variety of built-in Underpost global scripts, their preset lifecycle events, and arbitrary custom scripts.
|
|
29
|
-
cron [options] [deploy-list] [job-list] Manages cron jobs, including initialization, execution, and configuration updates.
|
|
30
|
-
fs [options] [path] Manages file storage, defaulting to file upload operations.
|
|
31
|
-
test [options] [deploy-list] Manages and runs tests, defaulting to the current Underpost default test suite.
|
|
32
|
-
monitor [options] <deploy-id> [env] Manages health server monitoring for specified deployments.
|
|
33
|
-
ssh [options] Import and start ssh server and client based on current default deployment ID.
|
|
34
|
-
run [options] <runner-id> [path] Runs a script from the specified path.
|
|
35
|
-
lxd [options] Manages LXD containers and virtual machines.
|
|
36
|
-
baremetal [options] [workflow-id] [hostname] [ip-address] Manages baremetal server operations, including installation, database setup, commissioning, and user management.
|
|
37
|
-
help [command] display help for command
|
|
38
|
-
|
|
10
|
+
new [options] <app-name> Initializes a new Underpost project with a predefined structure.
|
|
11
|
+
start [options] <deploy-id> [env] Initiates application servers, build pipelines, or other defined services based on the deployment ID.
|
|
12
|
+
clone [options] <uri> Clones a specified GitHub repository into the current directory.
|
|
13
|
+
pull [options] <path> <uri> Pulls the latest changes from a specified GitHub repository.
|
|
14
|
+
cmt [options] <path> <commit-type> [module-tag] [message] Manages commits to a GitHub repository, supporting various commit types and options.
|
|
15
|
+
push [options] <path> <uri> Pushes committed changes from a local repository to a remote GitHub repository.
|
|
16
|
+
env <deploy-id> [env] Sets environment variables and configurations related to a specific deployment ID.
|
|
17
|
+
config [options] <operator> [key] [value] Manages Underpost configurations using various operators.
|
|
18
|
+
root Displays the root path of the npm installation.
|
|
19
|
+
cluster [options] [pod-name] Manages Kubernetes clusters, defaulting to Kind cluster initialization.
|
|
20
|
+
deploy [options] [deploy-list] [env] Manages application deployments, defaulting to deploying development pods.
|
|
21
|
+
secret [options] <platform> Manages secrets for various platforms.
|
|
22
|
+
dockerfile-image-build [options] Builds a Docker image from a specified Dockerfile with various options for naming, saving, and loading.
|
|
23
|
+
dockerfile-pull-base-images [options] Pulls required Underpost Dockerfile base images and optionally loads them into clusters.
|
|
24
|
+
install Quickly imports Underpost npm dependencies by copying them.
|
|
25
|
+
db [options] <deploy-list> Manages database operations, including import, export, and collection management.
|
|
26
|
+
metadata [options] [deploy-id] [host] [path] Manages cluster metadata operations, including import and export.
|
|
27
|
+
script [options] <operator> <script-name> [script-value] Supports a variety of built-in Underpost global scripts, their preset lifecycle events, and arbitrary custom scripts.
|
|
28
|
+
cron [options] [deploy-list] [job-list] Manages cron jobs, including initialization, execution, and configuration updates.
|
|
29
|
+
fs [options] [path] Manages file storage, defaulting to file upload operations.
|
|
30
|
+
test [options] [deploy-list] Manages and runs tests, defaulting to the current Underpost default test suite.
|
|
31
|
+
monitor [options] <deploy-id> [env] Manages health server monitoring for specified deployments.
|
|
32
|
+
ssh [options] Import and start ssh server and client based on current default deployment ID.
|
|
33
|
+
run [options] <runner-id> [path] Runs a script from the specified path.
|
|
34
|
+
lxd [options] Manages LXD containers and virtual machines.
|
|
35
|
+
baremetal [options] [workflow-id] [hostname] [ip-address] Manages baremetal server operations, including installation, database setup, commissioning, and user management.
|
|
36
|
+
help [command] display help for command
|
|
37
|
+
|
|
39
38
|
```
|
|
40
39
|
|
|
41
40
|
## Commands:
|
|
41
|
+
|
|
42
42
|
|
|
43
43
|
### `new` :
|
|
44
|
-
|
|
45
44
|
```
|
|
46
45
|
Usage: underpost new [options] <app-name>
|
|
47
46
|
|
|
48
47
|
Initializes a new Underpost project with a predefined structure.
|
|
49
48
|
|
|
50
49
|
Arguments:
|
|
51
|
-
app-name
|
|
50
|
+
app-name The name or deploy-id of the application to create.
|
|
52
51
|
|
|
53
52
|
Options:
|
|
54
|
-
--
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
--deploy-id Crete deploy ID conf env files
|
|
54
|
+
--dev Sets the development cli context
|
|
55
|
+
-h, --help display help for command
|
|
56
|
+
|
|
57
57
|
```
|
|
58
|
+
|
|
58
59
|
|
|
59
60
|
### `start` :
|
|
60
|
-
|
|
61
61
|
```
|
|
62
62
|
Usage: underpost start [options] <deploy-id> [env]
|
|
63
63
|
|
|
@@ -73,11 +73,11 @@ Options:
|
|
|
73
73
|
--run Starts application servers and monitors their health.
|
|
74
74
|
--build Triggers the client-side application build process.
|
|
75
75
|
-h, --help display help for command
|
|
76
|
-
|
|
76
|
+
|
|
77
77
|
```
|
|
78
|
+
|
|
78
79
|
|
|
79
80
|
### `clone` :
|
|
80
|
-
|
|
81
81
|
```
|
|
82
82
|
Usage: underpost clone [options] <uri>
|
|
83
83
|
|
|
@@ -90,11 +90,11 @@ Options:
|
|
|
90
90
|
--bare Performs a bare clone, downloading only the .git files.
|
|
91
91
|
-g8 Uses the g8 repository extension for cloning.
|
|
92
92
|
-h, --help display help for command
|
|
93
|
-
|
|
93
|
+
|
|
94
94
|
```
|
|
95
|
+
|
|
95
96
|
|
|
96
97
|
### `pull` :
|
|
97
|
-
|
|
98
98
|
```
|
|
99
99
|
Usage: underpost pull [options] <path> <uri>
|
|
100
100
|
|
|
@@ -108,11 +108,11 @@ Arguments:
|
|
|
108
108
|
Options:
|
|
109
109
|
-g8 Uses the g8 repository extension for pulling.
|
|
110
110
|
-h, --help display help for command
|
|
111
|
-
|
|
111
|
+
|
|
112
112
|
```
|
|
113
|
+
|
|
113
114
|
|
|
114
115
|
### `cmt` :
|
|
115
|
-
|
|
116
116
|
```
|
|
117
117
|
Usage: underpost cmt [options] <path> <commit-type> [module-tag] [message]
|
|
118
118
|
|
|
@@ -132,11 +132,11 @@ Options:
|
|
|
132
132
|
--copy Copies the generated commit message to the clipboard.
|
|
133
133
|
--info Displays information about available commit types.
|
|
134
134
|
-h, --help display help for command
|
|
135
|
-
|
|
135
|
+
|
|
136
136
|
```
|
|
137
|
+
|
|
137
138
|
|
|
138
139
|
### `push` :
|
|
139
|
-
|
|
140
140
|
```
|
|
141
141
|
Usage: underpost push [options] <path> <uri>
|
|
142
142
|
|
|
@@ -150,11 +150,11 @@ Options:
|
|
|
150
150
|
-f Forces the push, overwriting the remote repository history.
|
|
151
151
|
-g8 Uses the g8 repository extension for pushing.
|
|
152
152
|
-h, --help display help for command
|
|
153
|
-
|
|
153
|
+
|
|
154
154
|
```
|
|
155
|
+
|
|
155
156
|
|
|
156
157
|
### `env` :
|
|
157
|
-
|
|
158
158
|
```
|
|
159
159
|
Usage: underpost env [options] <deploy-id> [env]
|
|
160
160
|
|
|
@@ -169,11 +169,11 @@ Arguments:
|
|
|
169
169
|
|
|
170
170
|
Options:
|
|
171
171
|
-h, --help display help for command
|
|
172
|
-
|
|
172
|
+
|
|
173
173
|
```
|
|
174
|
+
|
|
174
175
|
|
|
175
176
|
### `config` :
|
|
176
|
-
|
|
177
177
|
```
|
|
178
178
|
Usage: underpost config [options] <operator> [key] [value]
|
|
179
179
|
|
|
@@ -188,11 +188,11 @@ Arguments:
|
|
|
188
188
|
Options:
|
|
189
189
|
--plain Prints the configuration value in plain text.
|
|
190
190
|
-h, --help display help for command
|
|
191
|
-
|
|
191
|
+
|
|
192
192
|
```
|
|
193
|
+
|
|
193
194
|
|
|
194
195
|
### `root` :
|
|
195
|
-
|
|
196
196
|
```
|
|
197
197
|
Usage: underpost root [options]
|
|
198
198
|
|
|
@@ -200,11 +200,11 @@ Displays the root path of the npm installation.
|
|
|
200
200
|
|
|
201
201
|
Options:
|
|
202
202
|
-h, --help display help for command
|
|
203
|
-
|
|
203
|
+
|
|
204
204
|
```
|
|
205
|
+
|
|
205
206
|
|
|
206
207
|
### `cluster` :
|
|
207
|
-
|
|
208
208
|
```
|
|
209
209
|
Usage: underpost cluster [options] [pod-name]
|
|
210
210
|
|
|
@@ -261,11 +261,11 @@ Options:
|
|
|
261
261
|
--k3s Initializes the cluster using K3s (Lightweight
|
|
262
262
|
Kubernetes).
|
|
263
263
|
-h, --help display help for command
|
|
264
|
-
|
|
264
|
+
|
|
265
265
|
```
|
|
266
|
+
|
|
266
267
|
|
|
267
268
|
### `deploy` :
|
|
268
|
-
|
|
269
269
|
```
|
|
270
270
|
Usage: underpost deploy [options] [deploy-list] [env]
|
|
271
271
|
|
|
@@ -291,6 +291,8 @@ Options:
|
|
|
291
291
|
management commands.
|
|
292
292
|
--cert Resets TLS/SSL certificate secrets for
|
|
293
293
|
deployments.
|
|
294
|
+
--node <node> Sets optional node for deployment
|
|
295
|
+
operations.
|
|
294
296
|
--build-manifest Builds Kubernetes YAML manifests, including
|
|
295
297
|
deployments, services, proxies, and
|
|
296
298
|
secrets.
|
|
@@ -307,11 +309,11 @@ Options:
|
|
|
307
309
|
operations.
|
|
308
310
|
--restore-hosts Restores default `/etc/hosts` entries.
|
|
309
311
|
-h, --help display help for command
|
|
310
|
-
|
|
312
|
+
|
|
311
313
|
```
|
|
314
|
+
|
|
312
315
|
|
|
313
316
|
### `secret` :
|
|
314
|
-
|
|
315
317
|
```
|
|
316
318
|
Usage: underpost secret [options] <platform>
|
|
317
319
|
|
|
@@ -329,11 +331,11 @@ Options:
|
|
|
329
331
|
--list Lists all available secrets for the
|
|
330
332
|
platform.
|
|
331
333
|
-h, --help display help for command
|
|
332
|
-
|
|
334
|
+
|
|
333
335
|
```
|
|
336
|
+
|
|
334
337
|
|
|
335
338
|
### `dockerfile-image-build` :
|
|
336
|
-
|
|
337
339
|
```
|
|
338
340
|
Usage: underpost dockerfile-image-build [options]
|
|
339
341
|
|
|
@@ -360,11 +362,11 @@ Options:
|
|
|
360
362
|
cache.
|
|
361
363
|
--k3s-load Loads the image into a K3s cluster.
|
|
362
364
|
-h, --help display help for command
|
|
363
|
-
|
|
365
|
+
|
|
364
366
|
```
|
|
367
|
+
|
|
365
368
|
|
|
366
369
|
### `dockerfile-pull-base-images` :
|
|
367
|
-
|
|
368
370
|
```
|
|
369
371
|
Usage: underpost dockerfile-pull-base-images [options]
|
|
370
372
|
|
|
@@ -378,11 +380,11 @@ Options:
|
|
|
378
380
|
--version Sets a custom version for the base images.
|
|
379
381
|
--k3s-load Loads the image into a K3s cluster.
|
|
380
382
|
-h, --help display help for command
|
|
381
|
-
|
|
383
|
+
|
|
382
384
|
```
|
|
385
|
+
|
|
383
386
|
|
|
384
387
|
### `install` :
|
|
385
|
-
|
|
386
388
|
```
|
|
387
389
|
Usage: underpost install [options]
|
|
388
390
|
|
|
@@ -390,11 +392,11 @@ Quickly imports Underpost npm dependencies by copying them.
|
|
|
390
392
|
|
|
391
393
|
Options:
|
|
392
394
|
-h, --help display help for command
|
|
393
|
-
|
|
395
|
+
|
|
394
396
|
```
|
|
397
|
+
|
|
395
398
|
|
|
396
399
|
### `db` :
|
|
397
|
-
|
|
398
400
|
```
|
|
399
401
|
Usage: underpost db [options] <deploy-list>
|
|
400
402
|
|
|
@@ -424,11 +426,11 @@ Options:
|
|
|
424
426
|
--ns <ns-name> Optional: Specifies the namespace context for
|
|
425
427
|
database operations.
|
|
426
428
|
-h, --help display help for command
|
|
427
|
-
|
|
429
|
+
|
|
428
430
|
```
|
|
431
|
+
|
|
429
432
|
|
|
430
433
|
### `metadata` :
|
|
431
|
-
|
|
432
434
|
```
|
|
433
435
|
Usage: underpost metadata [options] [deploy-id] [host] [path]
|
|
434
436
|
|
|
@@ -447,11 +449,11 @@ Options:
|
|
|
447
449
|
--generate Generate cluster metadata
|
|
448
450
|
--itc Apply under container execution context
|
|
449
451
|
-h, --help display help for command
|
|
450
|
-
|
|
452
|
+
|
|
451
453
|
```
|
|
454
|
+
|
|
452
455
|
|
|
453
456
|
### `script` :
|
|
454
|
-
|
|
455
457
|
```
|
|
456
458
|
Usage: underpost script [options] <operator> <script-name> [script-value]
|
|
457
459
|
|
|
@@ -473,11 +475,11 @@ Options:
|
|
|
473
475
|
execution.
|
|
474
476
|
--pod-name <pod-name> Optional: Specifies the pod name for script execution.
|
|
475
477
|
-h, --help display help for command
|
|
476
|
-
|
|
478
|
+
|
|
477
479
|
```
|
|
480
|
+
|
|
478
481
|
|
|
479
482
|
### `cron` :
|
|
480
|
-
|
|
481
483
|
```
|
|
482
484
|
Usage: underpost cron [options] [deploy-list] [job-list]
|
|
483
485
|
|
|
@@ -495,11 +497,11 @@ Options:
|
|
|
495
497
|
--init Initializes cron jobs for the default deployment ID.
|
|
496
498
|
--git Uploads cron job configurations to GitHub.
|
|
497
499
|
-h, --help display help for command
|
|
498
|
-
|
|
500
|
+
|
|
499
501
|
```
|
|
502
|
+
|
|
500
503
|
|
|
501
504
|
### `fs` :
|
|
502
|
-
|
|
503
505
|
```
|
|
504
506
|
Usage: underpost fs [options] [path]
|
|
505
507
|
|
|
@@ -517,11 +519,11 @@ Options:
|
|
|
517
519
|
--force Forces the action, overriding any warnings or conflicts.
|
|
518
520
|
--storage-file-path <storage-file-path> Specifies a custom file storage path.
|
|
519
521
|
-h, --help display help for command
|
|
520
|
-
|
|
522
|
+
|
|
521
523
|
```
|
|
524
|
+
|
|
522
525
|
|
|
523
526
|
### `test` :
|
|
524
|
-
|
|
525
527
|
```
|
|
526
528
|
Usage: underpost test [options] [deploy-list]
|
|
527
529
|
|
|
@@ -543,11 +545,11 @@ Options:
|
|
|
543
545
|
--kind-type <kind-type> Optional: Specifies the Kind cluster type for
|
|
544
546
|
tests.
|
|
545
547
|
-h, --help display help for command
|
|
546
|
-
|
|
548
|
+
|
|
547
549
|
```
|
|
550
|
+
|
|
548
551
|
|
|
549
552
|
### `monitor` :
|
|
550
|
-
|
|
551
553
|
```
|
|
552
554
|
Usage: underpost monitor [options] <deploy-id> [env]
|
|
553
555
|
|
|
@@ -570,11 +572,11 @@ Options:
|
|
|
570
572
|
--sync Synchronizes with current proxy deployments and
|
|
571
573
|
traffic configurations.
|
|
572
574
|
-h, --help display help for command
|
|
573
|
-
|
|
575
|
+
|
|
574
576
|
```
|
|
577
|
+
|
|
575
578
|
|
|
576
579
|
### `ssh` :
|
|
577
|
-
|
|
578
580
|
```
|
|
579
581
|
Usage: underpost ssh [options]
|
|
580
582
|
|
|
@@ -584,18 +586,18 @@ Options:
|
|
|
584
586
|
--generate Generates new ssh credential and stores it in current private
|
|
585
587
|
keys file storage.
|
|
586
588
|
-h, --help display help for command
|
|
587
|
-
|
|
589
|
+
|
|
588
590
|
```
|
|
591
|
+
|
|
589
592
|
|
|
590
593
|
### `run` :
|
|
591
|
-
|
|
592
594
|
```
|
|
593
595
|
Usage: underpost run [options] <runner-id> [path]
|
|
594
596
|
|
|
595
597
|
Runs a script from the specified path.
|
|
596
598
|
|
|
597
599
|
Arguments:
|
|
598
|
-
runner-id The runner ID to run. Options: spark-template, rmi, kill, secret, underpost-config, gpu-env, tf-gpu-test, dev-cluster, ssh-cluster-info, cyberia-ide, engine-ide, template-deploy, clean, pull, release-deploy, ssh-deploy, ide, dev-client, dev-api, monitor, db-client, promote, metrics, cluster, deploy, tf-vae-test, deploy-job.
|
|
600
|
+
runner-id The runner ID to run. Options: spark-template, rmi, kill, secret, underpost-config, gpu-env, tf-gpu-test, dev-cluster, ssh-cluster-info, cyberia-ide, engine-ide, template-deploy, clean, pull, release-deploy, ssh-deploy, ide, dev-client, dev-api, router-sync, monitor, db-client, promote, metrics, cluster, deploy, tf-vae-test, deploy-job.
|
|
599
601
|
path The absolute or relative directory path where the script is located.
|
|
600
602
|
|
|
601
603
|
Options:
|
|
@@ -610,11 +612,11 @@ Options:
|
|
|
610
612
|
--container-name <container-name> Optional: Specifies the container name for test execution.
|
|
611
613
|
--namespace <namespace> Optional: Specifies the namespace for test execution.
|
|
612
614
|
-h, --help display help for command
|
|
613
|
-
|
|
615
|
+
|
|
614
616
|
```
|
|
617
|
+
|
|
615
618
|
|
|
616
619
|
### `lxd` :
|
|
617
|
-
|
|
618
620
|
```
|
|
619
621
|
Usage: underpost lxd [options]
|
|
620
622
|
|
|
@@ -655,11 +657,11 @@ Options:
|
|
|
655
657
|
--auto-expose-k8s-ports <vm-id> Automatically exposes common Kubernetes
|
|
656
658
|
ports for the specified VM.
|
|
657
659
|
-h, --help display help for command
|
|
658
|
-
|
|
660
|
+
|
|
659
661
|
```
|
|
662
|
+
|
|
660
663
|
|
|
661
664
|
### `baremetal` :
|
|
662
|
-
|
|
663
665
|
```
|
|
664
666
|
Usage: underpost baremetal [options] [workflow-id] [hostname] [ip-address]
|
|
665
667
|
|
|
@@ -693,5 +695,6 @@ Options:
|
|
|
693
695
|
baremetal operations.
|
|
694
696
|
--ls Lists available boot resources and machines.
|
|
695
697
|
-h, --help display help for command
|
|
696
|
-
|
|
698
|
+
|
|
697
699
|
```
|
|
700
|
+
|
package/conf.js
CHANGED
|
@@ -130,7 +130,7 @@ const DefaultConf = /**/ {
|
|
|
130
130
|
ssr: {
|
|
131
131
|
Default: {
|
|
132
132
|
head: ['Seo', 'Pwa', 'Css', 'DefaultScripts', 'Production'],
|
|
133
|
-
body: ['CacheControl', 'DefaultSplashScreen'
|
|
133
|
+
body: ['CacheControl', 'DefaultSplashScreen'],
|
|
134
134
|
mailer: { userVerifyEmail: 'DefaultVerifyEmail', userRecoverEmail: 'DefaultRecoverEmail' },
|
|
135
135
|
offline: [
|
|
136
136
|
{ path: '/offline', title: 'No Network Connection', client: 'NoNetworkConnection', head: [], body: [] },
|
|
@@ -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.866
|
|
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.866
|
|
104
104
|
# resources:
|
|
105
105
|
# requests:
|
|
106
106
|
# memory: "124Ki"
|
package/package.json
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
"type": "module",
|
|
3
3
|
"main": "src/index.js",
|
|
4
4
|
"name": "underpost",
|
|
5
|
-
"version": "2.8.
|
|
5
|
+
"version": "2.8.866",
|
|
6
6
|
"description": "pwa api rest template",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"start": "env-cmd -f .env.production node --max-old-space-size=8192 src/server",
|
|
9
9
|
"build": "node bin/deploy build-full-client",
|
|
10
10
|
"test": "env-cmd -f .env.test c8 mocha",
|
|
11
|
-
"pm2": "env-cmd -f .env.production pm2 start src/server.js --node-args=\"--max-old-space-size=8192\" --name engine",
|
|
11
|
+
"pm2": "env-cmd -f .env.production pm2 start src/server.js --node-args=\"--max-old-space-size=8192\" --name engine -- dd-default",
|
|
12
12
|
"dev": "env-cmd -f .env.development nodemon src/server",
|
|
13
13
|
"dev-img": "env-cmd -f .env.development node src/server",
|
|
14
14
|
"prod-img": "env-cmd -f .env.production node src/server",
|
package/src/cli/cluster.js
CHANGED
|
@@ -683,17 +683,9 @@ net.ipv4.ip_forward = 1' | sudo tee ${iptableConfPath}`,
|
|
|
683
683
|
}
|
|
684
684
|
},
|
|
685
685
|
|
|
686
|
-
|
|
687
|
-
* @method getResourcesCapacity
|
|
688
|
-
* @description Retrieves and returns the allocatable CPU and memory resources
|
|
689
|
-
* of the Kubernetes node.
|
|
690
|
-
* @param {boolean} [isKubeadmOrK3s=false] - If true, assumes a kubeadm or k3s-managed node;
|
|
691
|
-
* otherwise, assumes a Kind worker node.
|
|
692
|
-
* @returns {object} An object containing CPU and memory resources with values and units.
|
|
693
|
-
*/
|
|
694
|
-
getResourcesCapacity(isKubeadmOrK3s = false) {
|
|
686
|
+
getResourcesCapacity(node) {
|
|
695
687
|
const resources = {};
|
|
696
|
-
const nodeName =
|
|
688
|
+
const nodeName = node ?? os.hostname();
|
|
697
689
|
const info = shellExec(`kubectl describe node ${nodeName} | grep -E '(Allocatable:|Capacity:)' -A 6`, {
|
|
698
690
|
stdout: true,
|
|
699
691
|
silent: true,
|
package/src/cli/deploy.js
CHANGED
|
@@ -22,13 +22,13 @@ const logger = loggerFactory(import.meta);
|
|
|
22
22
|
class UnderpostDeploy {
|
|
23
23
|
static NETWORK = {};
|
|
24
24
|
static API = {
|
|
25
|
-
sync(deployList, { versions, replicas,
|
|
25
|
+
sync(deployList, { versions, replicas, node }) {
|
|
26
26
|
const deployGroupId = 'dd.router';
|
|
27
27
|
fs.writeFileSync(`./engine-private/deploy/${deployGroupId}`, deployList, 'utf8');
|
|
28
28
|
const totalPods = deployList.split(',').length * versions.split(',').length * parseInt(replicas);
|
|
29
29
|
const limitFactor = 0.8;
|
|
30
30
|
const reserveFactor = 0.05;
|
|
31
|
-
const resources = UnderpostCluster.API.getResourcesCapacity(
|
|
31
|
+
const resources = UnderpostCluster.API.getResourcesCapacity(node);
|
|
32
32
|
const memory = parseInt(resources.memory.value / totalPods);
|
|
33
33
|
const cpu = parseInt(resources.cpu.value / totalPods);
|
|
34
34
|
UnderpostRootEnv.API.set(
|
|
@@ -49,7 +49,7 @@ class UnderpostDeploy {
|
|
|
49
49
|
const initEnvObj = dotenv.parse(fs.readFileSync(initEnvPath, 'utf8'));
|
|
50
50
|
process.env.PORT = initEnvObj.PORT;
|
|
51
51
|
process.env.NODE_ENV = env;
|
|
52
|
-
await Config.build(
|
|
52
|
+
await Config.build('proxy', deployList);
|
|
53
53
|
return buildPortProxyRouter(env === 'development' ? 80 : 443, buildProxyRouter());
|
|
54
54
|
},
|
|
55
55
|
deploymentYamlServiceFactory({ deployId, env, port, deploymentVersions }) {
|
|
@@ -243,6 +243,7 @@ spec:
|
|
|
243
243
|
versions: '',
|
|
244
244
|
traffic: '',
|
|
245
245
|
replicas: '',
|
|
246
|
+
node: '',
|
|
246
247
|
restoreHosts: false,
|
|
247
248
|
disableUpdateDeployment: false,
|
|
248
249
|
infoTraffic: false,
|
package/src/cli/index.js
CHANGED
|
@@ -22,7 +22,8 @@ program.name('underpost').description(`underpost ci/cd cli ${Underpost.version}`
|
|
|
22
22
|
// 'new' command: Create a new project
|
|
23
23
|
program
|
|
24
24
|
.command('new')
|
|
25
|
-
.argument('<app-name>', 'The name of the application to create.')
|
|
25
|
+
.argument('<app-name>', 'The name or deploy-id of the application to create.')
|
|
26
|
+
.option('--deploy-id', 'Crete deploy ID conf env files')
|
|
26
27
|
.option('--dev', 'Sets the development cli context')
|
|
27
28
|
.description('Initializes a new Underpost project with a predefined structure.')
|
|
28
29
|
.action(Underpost.repo.new);
|
|
@@ -157,6 +158,7 @@ program
|
|
|
157
158
|
.option('--expose', 'Exposes services matching the provided deployment ID list.')
|
|
158
159
|
.option('--info-util', 'Displays useful `kubectl` utility management commands.')
|
|
159
160
|
.option('--cert', 'Resets TLS/SSL certificate secrets for deployments.')
|
|
161
|
+
.option('--node <node>', 'Sets optional node for deployment operations.')
|
|
160
162
|
.option(
|
|
161
163
|
'--build-manifest',
|
|
162
164
|
'Builds Kubernetes YAML manifests, including deployments, services, proxies, and secrets.',
|
package/src/cli/repository.js
CHANGED
|
@@ -5,6 +5,7 @@ import { actionInitLog, loggerFactory } from '../server/logger.js';
|
|
|
5
5
|
import fs from 'fs-extra';
|
|
6
6
|
import { getNpmRootPath } from '../server/conf.js';
|
|
7
7
|
import UnderpostStartUp from '../server/start.js';
|
|
8
|
+
import { Config } from '../server/conf.js';
|
|
8
9
|
|
|
9
10
|
dotenv.config();
|
|
10
11
|
|
|
@@ -80,15 +81,16 @@ class UnderpostRepository {
|
|
|
80
81
|
);
|
|
81
82
|
},
|
|
82
83
|
|
|
83
|
-
new(repositoryName, options = { dev: false }) {
|
|
84
|
+
new(repositoryName, options = { dev: false, deployId: false }) {
|
|
84
85
|
return new Promise(async (resolve, reject) => {
|
|
85
86
|
try {
|
|
86
87
|
await logger.setUpInfo();
|
|
88
|
+
actionInitLog();
|
|
87
89
|
if (repositoryName === 'service')
|
|
88
90
|
return resolve(
|
|
89
91
|
await UnderpostStartUp.API.listenPortController(UnderpostStartUp.API.listenServerFactory(), ':'),
|
|
90
92
|
);
|
|
91
|
-
|
|
93
|
+
if (options.deployId === true) return Config.deployIdFactory(repositoryName);
|
|
92
94
|
const npmRoot = getNpmRootPath();
|
|
93
95
|
const underpostRoot = options?.dev === true ? '.' : `${npmRoot}/underpost`;
|
|
94
96
|
const destFolder = `./${repositoryName}`;
|
package/src/cli/run.js
CHANGED
|
@@ -141,6 +141,14 @@ class UnderpostRun {
|
|
|
141
141
|
let [deployId, subConf] = path.split(',');
|
|
142
142
|
shellExec(`npm run dev-api ${deployId} ${subConf}`);
|
|
143
143
|
},
|
|
144
|
+
'router-sync': (path, options = UnderpostRun.DEFAULT_OPTION) => {
|
|
145
|
+
const baseCommand = options.dev || true ? 'node bin' : 'underpost';
|
|
146
|
+
const defaultPaht = ['dd', 'kind-control-plane'];
|
|
147
|
+
let [deployId, node] = path ? path.split(',') : defaultPaht;
|
|
148
|
+
deployId = deployId ?? defaultPaht[0];
|
|
149
|
+
node = node ?? defaultPaht[1];
|
|
150
|
+
shellExec(`${baseCommand} deploy --sync --node ${node} --build-manifest --info-router ${deployId} production`);
|
|
151
|
+
},
|
|
144
152
|
monitor: (path, options = UnderpostRun.DEFAULT_OPTION) => {
|
|
145
153
|
const pid = getTerminalPid();
|
|
146
154
|
logger.info('monitor pid', pid);
|
package/src/index.js
CHANGED
|
@@ -535,13 +535,7 @@ Sitemap: https://${host}${path === '/' ? '' : path}/sitemap.xml`,
|
|
|
535
535
|
);
|
|
536
536
|
}
|
|
537
537
|
|
|
538
|
-
if (
|
|
539
|
-
fullBuildEnabled &&
|
|
540
|
-
!enableLiveRebuild &&
|
|
541
|
-
!process.argv.includes('l') &&
|
|
542
|
-
!process.argv.includes('deploy') &&
|
|
543
|
-
docsBuild
|
|
544
|
-
) {
|
|
538
|
+
if (fullBuildEnabled && !enableLiveRebuild && !process.argv.includes('l') && docsBuild) {
|
|
545
539
|
await buildDocs({
|
|
546
540
|
host,
|
|
547
541
|
path,
|
package/src/server/conf.js
CHANGED
|
@@ -27,67 +27,84 @@ dotenv.config();
|
|
|
27
27
|
|
|
28
28
|
const logger = loggerFactory(import.meta);
|
|
29
29
|
|
|
30
|
-
// monitoring: https://app.pm2.io/
|
|
31
|
-
|
|
32
30
|
const Config = {
|
|
33
31
|
default: DefaultConf,
|
|
34
|
-
build: async function (
|
|
35
|
-
if (
|
|
32
|
+
build: async function (deployContext = 'dd-default', deployList, subConf) {
|
|
33
|
+
if (typeof process.argv[2] === 'string' && process.argv[2].startsWith('dd-')) deployContext = process.argv[2];
|
|
36
34
|
if (!fs.existsSync(`./tmp`)) fs.mkdirSync(`./tmp`, { recursive: true });
|
|
37
35
|
fs.writeFileSync(`./tmp/await-deploy`, '', 'utf8');
|
|
38
36
|
if (fs.existsSync(`./engine-private/replica/${deployContext}`))
|
|
39
37
|
return loadConf(deployContext, process.env.NODE_ENV, subConf);
|
|
40
38
|
else if (deployContext.startsWith('dd-')) return loadConf(deployContext, process.env.NODE_ENV, subConf);
|
|
39
|
+
if (deployContext === 'proxy') Config.buildProxy(deployContext, deployList, subConf);
|
|
40
|
+
},
|
|
41
|
+
deployIdFactory: function (deployId = 'dd-default') {
|
|
42
|
+
if (!deployId.startsWith('dd-')) deployId = `dd-${deployId}`;
|
|
41
43
|
|
|
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
|
-
|
|
44
|
+
logger.info('Build deployId', deployId);
|
|
45
|
+
|
|
46
|
+
const folder = `./engine-private/conf/${deployId}`;
|
|
47
|
+
|
|
48
|
+
if (!fs.existsSync(folder)) fs.mkdirSync(folder, { recursive: true });
|
|
49
|
+
fs.writeFileSync(
|
|
50
|
+
`${folder}/.env.production`,
|
|
51
|
+
fs.readFileSync('./.env.production', 'utf8').replace('dd-default', deployId),
|
|
52
|
+
'utf8',
|
|
53
|
+
);
|
|
54
|
+
fs.writeFileSync(
|
|
55
|
+
`${folder}/.env.development`,
|
|
56
|
+
fs.readFileSync('./.env.development', 'utf8').replace('dd-default', deployId),
|
|
57
|
+
'utf8',
|
|
58
|
+
);
|
|
59
|
+
fs.writeFileSync(
|
|
60
|
+
`${folder}/.env.test`,
|
|
61
|
+
fs.readFileSync('./.env.test', 'utf8').replace('dd-default', deployId),
|
|
62
|
+
'utf8',
|
|
63
|
+
);
|
|
64
|
+
fs.writeFileSync(`${folder}/package.json`, fs.readFileSync('./package.json', 'utf8'), 'utf8');
|
|
65
|
+
|
|
66
|
+
this.buildTmpConf(folder);
|
|
67
|
+
|
|
68
|
+
return { deployIdFolder: folder, deployId };
|
|
69
|
+
},
|
|
70
|
+
buildTmpConf: function (folder = './conf') {
|
|
71
|
+
for (const confType of Object.keys(this.default))
|
|
72
|
+
fs.writeFileSync(`${folder}/conf.${confType}.json`, JSON.stringify(this.default[confType], null, 4), 'utf8');
|
|
73
|
+
},
|
|
74
|
+
buildProxy: function (deployContext = 'dd-default', deployList, subConf) {
|
|
75
|
+
if (!deployList) deployList = process.argv[3];
|
|
76
|
+
if (!subConf) subConf = process.argv[4];
|
|
77
|
+
this.default.server = {};
|
|
78
|
+
for (const deployId of deployList.split(',')) {
|
|
79
|
+
let confPath = `./engine-private/conf/${deployId}/conf.server.json`;
|
|
80
|
+
const privateConfDevPath = fs.existsSync(`./engine-private/replica/${deployId}/conf.server.json`)
|
|
81
|
+
? `./engine-private/replica/${deployId}/conf.server.json`
|
|
82
|
+
: `./engine-private/conf/${deployId}/conf.server.dev.${subConf}.json`;
|
|
83
|
+
const confDevPath = fs.existsSync(privateConfDevPath)
|
|
84
|
+
? privateConfDevPath
|
|
85
|
+
: `./engine-private/conf/${deployId}/conf.server.dev.json`;
|
|
86
|
+
|
|
87
|
+
if (process.env.NODE_ENV === 'development' && fs.existsSync(confDevPath)) confPath = confDevPath;
|
|
88
|
+
const serverConf = JSON.parse(fs.readFileSync(confPath, 'utf8'));
|
|
89
|
+
|
|
90
|
+
for (const host of Object.keys(loadReplicas(serverConf, deployContext, subConf))) {
|
|
91
|
+
if (serverConf[host]['/'])
|
|
92
|
+
this.default.server[host] = {
|
|
93
|
+
...this.default.server[host],
|
|
94
|
+
...serverConf[host],
|
|
95
|
+
};
|
|
96
|
+
else
|
|
97
|
+
this.default.server[host] = {
|
|
98
|
+
...serverConf[host],
|
|
99
|
+
...this.default.server[host],
|
|
100
|
+
};
|
|
72
101
|
}
|
|
73
102
|
}
|
|
74
|
-
|
|
75
|
-
options = {
|
|
76
|
-
...options,
|
|
77
|
-
folder: `./conf`,
|
|
78
|
-
};
|
|
79
|
-
if (!fs.existsSync(options.folder)) fs.mkdirSync(options.folder, { recursive: true });
|
|
80
|
-
for (const confType of Object.keys(this.default)) {
|
|
81
|
-
fs.writeFileSync(
|
|
82
|
-
`${options.folder}/conf.${confType}.json`,
|
|
83
|
-
JSON.stringify(this.default[confType], null, 4),
|
|
84
|
-
'utf8',
|
|
85
|
-
);
|
|
86
|
-
}
|
|
103
|
+
this.buildTmpConf();
|
|
87
104
|
},
|
|
88
105
|
};
|
|
89
106
|
|
|
90
|
-
const loadConf = (deployId, envInput, subConf) => {
|
|
107
|
+
const loadConf = (deployId = 'dd-default', envInput, subConf) => {
|
|
91
108
|
if (deployId === 'current') {
|
|
92
109
|
console.log(process.env.DEPLOY_ID);
|
|
93
110
|
return;
|
|
@@ -103,22 +120,15 @@ const loadConf = (deployId, envInput, subConf) => {
|
|
|
103
120
|
shellExec(`git checkout ${path}/package-lock.json`);
|
|
104
121
|
return;
|
|
105
122
|
}
|
|
106
|
-
if (!deployId.startsWith('dd-')) deployId = 'dd-default';
|
|
107
123
|
const folder = fs.existsSync(`./engine-private/replica/${deployId}`)
|
|
108
124
|
? `./engine-private/replica/${deployId}`
|
|
109
125
|
: `./engine-private/conf/${deployId}`;
|
|
126
|
+
if (!fs.existsSync(folder)) Config.deployIdFactory(deployId);
|
|
110
127
|
if (!fs.existsSync(`./conf`)) fs.mkdirSync(`./conf`);
|
|
111
|
-
if (!fs.existsSync(`./tmp`)) fs.mkdirSync(`./tmp
|
|
112
|
-
|
|
113
|
-
if (!isValidDeployId) {
|
|
114
|
-
logger.info(`Save new deploy conf: '${deployId}'`);
|
|
115
|
-
shellExec(`node bin/deploy save ${deployId}`);
|
|
116
|
-
return loadConf(deployId);
|
|
117
|
-
}
|
|
128
|
+
if (!fs.existsSync(`./tmp`)) fs.mkdirSync(`./tmp`);
|
|
129
|
+
|
|
118
130
|
for (const typeConf of Object.keys(Config.default)) {
|
|
119
|
-
let srcConf =
|
|
120
|
-
? fs.readFileSync(`${folder}/conf.${typeConf}.json`, 'utf8')
|
|
121
|
-
: JSON.stringify(Config.default[typeConf]);
|
|
131
|
+
let srcConf = fs.readFileSync(`${folder}/conf.${typeConf}.json`, 'utf8');
|
|
122
132
|
if (process.env.NODE_ENV === 'development' && typeConf === 'server') {
|
|
123
133
|
if (!subConf) subConf = process.argv[3];
|
|
124
134
|
const devConfPath = `${folder}/conf.${typeConf}.dev${subConf ? `.${subConf}` : ''}.json`;
|
|
@@ -493,15 +503,6 @@ const buildProxyRouter = () => {
|
|
|
493
503
|
}
|
|
494
504
|
}
|
|
495
505
|
}
|
|
496
|
-
if (process.argv.includes('maintenance'))
|
|
497
|
-
(async () => {
|
|
498
|
-
globalThis.defaultHtmlSrcMaintenance = (await ssrFactory())({
|
|
499
|
-
title: 'Site in maintenance',
|
|
500
|
-
ssrPath: '/',
|
|
501
|
-
ssrHeadComponents: '',
|
|
502
|
-
ssrBodyComponents: (await ssrFactory(`./src/client/ssr/offline/Maintenance.js`))(),
|
|
503
|
-
});
|
|
504
|
-
})();
|
|
505
506
|
|
|
506
507
|
return proxyRouter;
|
|
507
508
|
};
|
|
@@ -635,7 +636,6 @@ const getDataDeploy = (
|
|
|
635
636
|
deployGroupId: '',
|
|
636
637
|
deployId: '',
|
|
637
638
|
disableSyncEnvPort: false,
|
|
638
|
-
deployIdConcat: [],
|
|
639
639
|
},
|
|
640
640
|
) => {
|
|
641
641
|
let dataDeploy =
|
|
@@ -648,8 +648,6 @@ const getDataDeploy = (
|
|
|
648
648
|
.map((deployId) => deployId.trim())
|
|
649
649
|
.filter((deployId) => deployId);
|
|
650
650
|
|
|
651
|
-
if (options.deployIdConcat) dataDeploy = dataDeploy.concat(options.deployIdConcat);
|
|
652
|
-
|
|
653
651
|
if (options.deployId) dataDeploy = dataDeploy.filter((d) => d === options.deployId);
|
|
654
652
|
|
|
655
653
|
dataDeploy = dataDeploy.map((deployId) => {
|
|
@@ -776,12 +774,6 @@ const awaitDeployMonitor = async (init = false, deltaMs = 1000) => {
|
|
|
776
774
|
if (fs.existsSync(`./tmp/await-deploy`)) return await awaitDeployMonitor();
|
|
777
775
|
};
|
|
778
776
|
|
|
779
|
-
const getDeployId = () => {
|
|
780
|
-
const deployIndexArg = process.argv.findIndex((a) => a.match(`deploy-id:`));
|
|
781
|
-
if (deployIndexArg > -1) return process.argv[deployIndexArg].split(':')[1].trim();
|
|
782
|
-
return 'dd-default';
|
|
783
|
-
};
|
|
784
|
-
|
|
785
777
|
const getCronBackUpFolder = (host = '', path = '') => {
|
|
786
778
|
return `${host}${path.replace(/\\/g, '/').replace(`/`, '-')}`;
|
|
787
779
|
};
|
|
@@ -998,7 +990,6 @@ export {
|
|
|
998
990
|
buildReplicaId,
|
|
999
991
|
getCronBackUpFolder,
|
|
1000
992
|
mergeFile,
|
|
1001
|
-
getDeployId,
|
|
1002
993
|
getPathsSSR,
|
|
1003
994
|
buildKindPorts,
|
|
1004
995
|
buildPortProxyRouter,
|
package/src/server/proxy.js
CHANGED
|
@@ -55,7 +55,7 @@ const buildProxy = async () => {
|
|
|
55
55
|
// '^/target-path': '/',
|
|
56
56
|
},
|
|
57
57
|
};
|
|
58
|
-
|
|
58
|
+
options.router = buildPortProxyRouter(port, proxyRouter);
|
|
59
59
|
|
|
60
60
|
const filter = false
|
|
61
61
|
? (pathname, req) => {
|
package/src/server/runtime.js
CHANGED
|
@@ -18,7 +18,6 @@ import { DataBaseProvider } from '../db/DataBaseProvider.js';
|
|
|
18
18
|
// import { createProxyMiddleware } from 'http-proxy-middleware';
|
|
19
19
|
import { createPeerServer } from './peer.js';
|
|
20
20
|
import { Lampp } from '../runtime/lampp/Lampp.js';
|
|
21
|
-
import { getDeployId } from './conf.js';
|
|
22
21
|
import { JSONweb, ssrFactory } from './client-formatted.js';
|
|
23
22
|
import Underpost from '../index.js';
|
|
24
23
|
import { createValkeyConnection } from './valkey.js';
|
|
@@ -28,7 +27,7 @@ dotenv.config();
|
|
|
28
27
|
const logger = loggerFactory(import.meta);
|
|
29
28
|
|
|
30
29
|
const buildRuntime = async () => {
|
|
31
|
-
const deployId =
|
|
30
|
+
const deployId = process.env.DEPLOY_ID;
|
|
32
31
|
|
|
33
32
|
const collectDefaultMetrics = promClient.collectDefaultMetrics;
|
|
34
33
|
collectDefaultMetrics();
|
package/src/server/start.js
CHANGED
|
@@ -107,12 +107,12 @@ class UnderpostStartUp {
|
|
|
107
107
|
for (const replica of replicas) {
|
|
108
108
|
if (!replica.match(deployId)) continue;
|
|
109
109
|
shellExec(`node bin/deploy conf ${replica} ${env}`);
|
|
110
|
-
shellExec(`npm ${runCmd}
|
|
110
|
+
shellExec(`npm ${runCmd} ${replica}`, { async: true });
|
|
111
111
|
await awaitDeployMonitor(true);
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
shellExec(`node bin/deploy conf ${deployId} ${env}`);
|
|
115
|
-
shellExec(`npm ${runCmd}
|
|
115
|
+
shellExec(`npm ${runCmd} ${deployId}`, { async: true });
|
|
116
116
|
await awaitDeployMonitor(true);
|
|
117
117
|
UnderpostRootEnv.API.set('container-status', `${deployId}-${env}-running-deployment`);
|
|
118
118
|
},
|