underpost 2.8.841 → 2.8.844

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.
Files changed (36) hide show
  1. package/.env.development +1 -0
  2. package/.env.production +1 -0
  3. package/.env.test +1 -0
  4. package/.github/workflows/{ghpkg.yml → ghpkg.ci.yml} +1 -1
  5. package/.github/workflows/{npmpkg.yml → npmpkg.ci.yml} +1 -1
  6. package/.github/workflows/{publish.yml → publish.ci.yml} +1 -1
  7. package/.github/workflows/{pwa-microservices-template.page.yml → pwa-microservices-template-page.cd.yml} +1 -1
  8. package/.github/workflows/{pwa-microservices-template.test.yml → pwa-microservices-template-test.ci.yml} +1 -1
  9. package/.vscode/settings.json +0 -1
  10. package/README.md +16 -2
  11. package/bin/build.js +8 -4
  12. package/bin/deploy.js +10 -81
  13. package/bin/file.js +15 -8
  14. package/cli.md +48 -43
  15. package/docker-compose.yml +1 -1
  16. package/manifests/deployment/dd-template-development/deployment.yaml +2 -2
  17. package/manifests/maas/gpu-diag.sh +1 -1
  18. package/package.json +4 -5
  19. package/src/api/user/user.router.js +24 -1
  20. package/src/cli/cluster.js +19 -10
  21. package/src/cli/deploy.js +19 -0
  22. package/src/cli/index.js +9 -1
  23. package/src/cli/monitor.js +8 -12
  24. package/src/cli/run.js +80 -0
  25. package/src/client/components/core/CssCore.js +0 -4
  26. package/src/client/components/core/Docs.js +1 -47
  27. package/src/client/components/core/EventsUI.js +92 -5
  28. package/src/client/components/core/Modal.js +431 -87
  29. package/src/client/components/core/NotificationManager.js +2 -2
  30. package/src/client/components/core/Panel.js +2 -2
  31. package/src/client/components/core/PanelForm.js +2 -0
  32. package/src/client/components/core/Recover.js +1 -1
  33. package/src/index.js +1 -1
  34. package/src/monitor.js +24 -0
  35. package/src/server/client-build.js +0 -20
  36. package/src/server/valkey.js +102 -41
package/.env.development CHANGED
@@ -1,3 +1,4 @@
1
+ DEPLOY_ID=dd-template
1
2
  NODE_ENV=development
2
3
  PORT=4000
3
4
  JWT_SECRET=test
package/.env.production CHANGED
@@ -1,3 +1,4 @@
1
+ DEPLOY_ID=dd-template
1
2
  NODE_ENV=production
2
3
  PORT=3000
3
4
  JWT_SECRET=test
package/.env.test CHANGED
@@ -1,3 +1,4 @@
1
+ DEPLOY_ID=dd-template
1
2
  NODE_ENV=test
2
3
  PORT=5000
3
4
  JWT_SECRET=test
@@ -1,4 +1,4 @@
1
- name: Update github repo package
1
+ name: CI | Publish github repository package
2
2
  on:
3
3
  push:
4
4
  branches: ['master']
@@ -1,4 +1,4 @@
1
- name: Update npm repo package
1
+ name: CI | Publish npm repository package
2
2
  on:
3
3
  push:
4
4
  branches: ['master']
@@ -1,4 +1,4 @@
1
- name: publish to npmjs
1
+ name: CI | Publish npm package
2
2
  on:
3
3
  release:
4
4
  types: [released]
@@ -1,5 +1,5 @@
1
1
  # Simple workflow for deploying static content to GitHub Pages
2
- name: Deploy static content to Pages
2
+ name: CD | Gihub page | PWA Microservices Template
3
3
 
4
4
  on:
5
5
  # Runs on pushes targeting the default branch
@@ -1,4 +1,4 @@
1
- name: Test
1
+ name: CI | Gihub page | PWA Microservices Template Test
2
2
 
3
3
  on: [push]
4
4
 
@@ -57,7 +57,6 @@
57
57
  "nexodev",
58
58
  "pathfinding",
59
59
  "Pixi",
60
- "plantuml",
61
60
  "privkey",
62
61
  "runas",
63
62
  "Scatterplot",
package/README.md CHANGED
@@ -28,10 +28,17 @@ template
28
28
 
29
29
 
30
30
 
31
+
32
+
33
+
34
+
35
+
36
+
37
+
31
38
  <!-- badges -->
32
39
 
33
40
 
34
- [![Node.js CI](https://github.com/underpostnet/engine/actions/workflows/docker-image.yml/badge.svg?branch=master)](https://github.com/underpostnet/engine/actions/workflows/docker-image.yml) [![Test](https://github.com/underpostnet/engine/actions/workflows/coverall.yml/badge.svg?branch=master)](https://github.com/underpostnet/engine/actions/workflows/coverall.yml) [![Downloads](https://img.shields.io/npm/dm/underpost.svg)](https://www.npmjs.com/package/underpost) [![Socket Badge](https://socket.dev/api/badge/npm/package/underpost/2.8.841)](https://socket.dev/npm/package/underpost/overview/2.8.841) [![Coverage Status](https://coveralls.io/repos/github/underpostnet/engine/badge.svg?branch=master)](https://coveralls.io/github/underpostnet/engine?branch=master) [![Version](https://img.shields.io/npm/v/underpost.svg)](https://www.npmjs.org/package/underpost) [![License](https://img.shields.io/npm/l/underpost.svg)](https://www.npmjs.com/package/underpost)
41
+ [![Node.js CI](https://github.com/underpostnet/engine/actions/workflows/docker-image.ci.yml/badge.svg?branch=master)](https://github.com/underpostnet/engine/actions/workflows/docker-image.yml) [![Test](https://github.com/underpostnet/engine/actions/workflows/coverall.ci.yml/badge.svg?branch=master)](https://github.com/underpostnet/engine/actions/workflows/coverall.yml) [![Downloads](https://img.shields.io/npm/dm/underpost.svg)](https://www.npmjs.com/package/underpost) [![Socket Badge](https://socket.dev/api/badge/npm/package/underpost/2.8.844)](https://socket.dev/npm/package/underpost/overview/2.8.844) [![Coverage Status](https://coveralls.io/repos/github/underpostnet/engine/badge.svg?branch=master)](https://coveralls.io/github/underpostnet/engine?branch=master) [![Version](https://img.shields.io/npm/v/underpost.svg)](https://www.npmjs.org/package/underpost) [![License](https://img.shields.io/npm/l/underpost.svg)](https://www.npmjs.com/package/underpost)
35
42
 
36
43
 
37
44
  <!-- end-badges -->
@@ -42,6 +49,13 @@ template
42
49
 
43
50
 
44
51
 
52
+
53
+
54
+
55
+
56
+
57
+
58
+
45
59
  </div>
46
60
 
47
61
  <div align="center">
@@ -86,7 +100,7 @@ Run dev client server
86
100
  npm run dev
87
101
  ```
88
102
  <!-- -->
89
- ## underpost ci/cd cli v2.8.841
103
+ ## underpost ci/cd cli v2.8.844
90
104
 
91
105
  ### Usage: `underpost [options] [command]`
92
106
  ```
package/bin/build.js CHANGED
@@ -150,10 +150,6 @@ const { DefaultConf } = await import(`../conf.${confName}.js`);
150
150
  shellExec(`node bin/deploy update-default-conf ${confName}`);
151
151
 
152
152
  fs.copyFileSync(`./conf.${confName}.js`, `${basePath}/conf.js`);
153
- fs.copyFileSync(
154
- `./.github/workflows/engine.${confName.split('dd-')[1]}.ci.yml`,
155
- `${basePath}/.github/workflows/engine.${confName.split('dd-')[1]}.ci.yml`,
156
- );
157
153
 
158
154
  switch (confName) {
159
155
  case 'dd-cyberia':
@@ -183,4 +179,12 @@ const { DefaultConf } = await import(`../conf.${confName}.js`);
183
179
  fs.copyFileSync(`./manifests/deployment/${confName}-${env}/${file}`, `${basePath}/${file}`);
184
180
  }
185
181
  }
182
+
183
+ if (!fs.existsSync(`${basePath}/.github/workflows`))
184
+ fs.mkdirSync(`${basePath}/.github/workflows`, {
185
+ recursive: true,
186
+ });
187
+
188
+ fs.copyFileSync(`./.github/workflows/${repoName}.ci.yml`, `${basePath}/.github/workflows/${repoName}.ci.yml`);
189
+ fs.copyFileSync(`./.github/workflows/${repoName}.cd.yml`, `${basePath}/.github/workflows/${repoName}.cd.yml`);
186
190
  }
package/bin/deploy.js CHANGED
@@ -531,74 +531,6 @@ try {
531
531
  if (!proxyInstance) for (const host of Object.keys(serverConf)) port += Object.keys(serverConf[host]).length;
532
532
  }
533
533
  break;
534
- case 'uml':
535
- {
536
- shellExec(`node bin/deploy fix-uml ${process.argv.slice(3).join(' ')}`);
537
- shellExec(`node bin/deploy build-uml ${process.argv.slice(3).join(' ')}`);
538
- }
539
- break;
540
-
541
- case 'fix-uml': {
542
- // required: java jdk-11.0.1
543
-
544
- // comment:
545
- // '--add-opens=java.xml/com.sun.org.apache.xalan.internal.xsltc.trax="ALL-UNNAMED"'
546
- // in plantuml.js src
547
-
548
- // const deployId = process.argv[3];
549
- // const clientId = process.argv[4];
550
- // const folder = `./src/client/public/${clientId ? clientId : 'default'}/docs/plantuml`;
551
- // const privateConfFolder = `./engine-private/conf/${deployId}`;
552
- // const confData = !deployId
553
- // ? Config.default
554
- // : {
555
- // client: JSON.parse(fs.readFileSync(`${privateConfFolder}/conf.client.json`, 'utf8')),
556
- // ssr: JSON.parse(fs.readFileSync(`${privateConfFolder}/conf.ssr.json`, 'utf8')),
557
- // server: JSON.parse(fs.readFileSync(`${privateConfFolder}/conf.server.json`, 'utf8')),
558
- // cron: JSON.parse(fs.readFileSync(`${privateConfFolder}/conf.cron.json`, 'utf8')),
559
- // };
560
-
561
- fs.writeFileSync(
562
- `./node_modules/plantuml/lib/plantuml.js`,
563
- fs
564
- .readFileSync(`./node_modules/plantuml/lib/plantuml.js`, 'utf8')
565
- .replace(`'--add-opens=java.xml/com.sun.org.apache.xalan.internal.xsltc.trax="ALL-UNNAMED"'`, `//`),
566
- );
567
- }
568
- case 'build-uml':
569
- {
570
- const plantuml = await import('plantuml');
571
- const folder = process.argv[3] ? process.argv[3] : `./src/client/public/default/plantuml`;
572
- const confData = Config.default;
573
-
574
- if (!fs.existsSync(folder)) fs.mkdirSync(folder, { recursive: true });
575
-
576
- for (const typeConf of Object.keys(confData)) {
577
- logger.info(`generate ${typeConf} instance`);
578
- try {
579
- const svg = await plantuml(`
580
- @startjson
581
- ${JSON.stringify(confData[typeConf])}
582
- @endjson
583
- `);
584
- fs.writeFileSync(`${folder}/${typeConf}-conf.svg`, svg);
585
- } catch (error) {
586
- logger.error(error, error.stack);
587
- }
588
- logger.info(`generate ${typeConf} schema`);
589
- try {
590
- const svg = await plantuml(`
591
- @startjson
592
- ${JSON.stringify(ejs(confData[typeConf]))}
593
- @endjson
594
- `);
595
- fs.writeFileSync(`${folder}/${typeConf}-schema.svg`, svg);
596
- } catch (error) {
597
- logger.error(error, error.stack);
598
- }
599
- }
600
- }
601
- break;
602
534
 
603
535
  case 'build-single-replica': {
604
536
  const deployId = process.argv[3];
@@ -682,6 +614,15 @@ try {
682
614
  }
683
615
 
684
616
  case 'version-build': {
617
+ shellCd(`/home/dd/engine`);
618
+ shellExec(`git reset`);
619
+ shellExec(`git checkout .`);
620
+ shellExec(`git clean -f -d`);
621
+ shellCd(`/home/dd/engine/engine-private`);
622
+ shellExec(`git reset`);
623
+ shellExec(`git checkout .`);
624
+ shellExec(`git clean -f -d`);
625
+ shellCd(`/home/dd/engine`);
685
626
  const originPackageJson = JSON.parse(fs.readFileSync(`package.json`, 'utf8'));
686
627
  const newVersion = process.argv[3] ?? originPackageJson.version;
687
628
  const { version } = originPackageJson;
@@ -863,7 +804,7 @@ ${shellExec(`git log | grep Author: | sort -u`, { stdout: true }).split(`\n`).jo
863
804
  // mongodb-0.mongodb-service
864
805
  DefaultConf.server[host][path].db.host = 'mongodb://mongodb-service:27017';
865
806
  confName = '';
866
- } else if (confName) {
807
+ } else if (confName && fs.existsSync(`./engine-private/conf/${confName}`)) {
867
808
  DefaultConf.client = JSON.parse(fs.readFileSync(`./engine-private/conf/${confName}/conf.client.json`, 'utf8'));
868
809
  DefaultConf.server = JSON.parse(fs.readFileSync(`./engine-private/conf/${confName}/conf.server.json`, 'utf8'));
869
810
  DefaultConf.ssr = JSON.parse(fs.readFileSync(`./engine-private/conf/${confName}/conf.ssr.json`, 'utf8'));
@@ -1110,18 +1051,6 @@ EOF`);
1110
1051
  break;
1111
1052
  }
1112
1053
 
1113
- case 'monitor': {
1114
- shellExec(
1115
- `node bin monitor ${process.argv[6] === 'sync' ? '--sync ' : ''}--type ${process.argv[3]} ${process.argv[4]} ${
1116
- process.argv[5]
1117
- }`,
1118
- {
1119
- async: true,
1120
- },
1121
- );
1122
- break;
1123
- }
1124
-
1125
1054
  case 'postgresql': {
1126
1055
  if (process.argv.includes('install')) {
1127
1056
  shellExec(`sudo dnf install -y postgresql-server postgresql`);
package/bin/file.js CHANGED
@@ -72,20 +72,14 @@ try {
72
72
 
73
73
  if (type === 'update-template') {
74
74
  fs.copySync(`./.vscode`, `../pwa-microservices-template/.vscode`);
75
- fs.copySync(`./.github`, `../pwa-microservices-template/.github`);
75
+ // fs.copySync(`./.github`, `../pwa-microservices-template/.github`);
76
76
  fs.copySync(`./src/client/public/default`, `../pwa-microservices-template/src/client/public/default`);
77
77
 
78
78
  for (const checkoutPath of ['README.md', 'package-lock.json', 'package.json'])
79
79
  shellExec(`cd ../pwa-microservices-template && git checkout ${checkoutPath}`);
80
80
 
81
81
  for (const deletePath of [
82
- '.github/workflows/coverall.yml',
83
- '.github/workflows/docker-image.yml',
84
- '.github/workflows/deploy.ssh.yml',
85
- '.github/workflows/deploy.api-rest.yml',
86
- '.github/workflows/engine.lampp.ci.yml',
87
- '.github/workflows/engine.core.ci.yml',
88
- '.github/workflows/engine.cyberia.ci.yml',
82
+ './.github',
89
83
  './manifests/deployment/dd-lampp-development',
90
84
  './manifests/deployment/dd-cyberia-development',
91
85
  './manifests/deployment/dd-core-development',
@@ -94,6 +88,19 @@ try {
94
88
  ]) {
95
89
  if (fs.existsSync(deletePath)) fs.removeSync('../pwa-microservices-template/' + deletePath);
96
90
  }
91
+
92
+ fs.mkdirSync(`../pwa-microservices-template/.github/workflows`, {
93
+ recursive: true,
94
+ });
95
+ for (const _path of [
96
+ `./.github/workflows/pwa-microservices-template-page.cd.yml`,
97
+ `./.github/workflows/pwa-microservices-template-test.ci.yml`,
98
+ `./.github/workflows/npmpkg.ci.yml`,
99
+ `./.github/workflows/ghpkg.ci.yml`,
100
+ `./.github/workflows/publish.ci.yml`,
101
+ ])
102
+ fs.copyFileSync(_path, `../pwa-microservices-template/${_path}`);
103
+
97
104
  const originPackageJson = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
98
105
  const templatePackageJson = JSON.parse(fs.readFileSync('../pwa-microservices-template/package.json', 'utf8'));
99
106
 
package/cli.md CHANGED
@@ -1,4 +1,4 @@
1
- ## underpost ci/cd cli v2.8.8411
1
+ ## underpost ci/cd cli v2.8.844
2
2
 
3
3
  ### Usage: `underpost [options] [command]`
4
4
  ```
@@ -206,49 +206,53 @@ Options:
206
206
  Manages Kubernetes clusters, defaulting to Kind cluster initialization.
207
207
 
208
208
  Arguments:
209
- pod-name Optional: Filters information by a specific pod name.
209
+ pod-name Optional: Filters information by a specific pod name.
210
210
 
211
211
  Options:
212
- --reset Deletes all clusters and prunes all related data and
213
- caches.
214
- --mariadb Initializes the cluster with a MariaDB statefulset.
215
- --mysql Initializes the cluster with a MySQL statefulset.
216
- --mongodb Initializes the cluster with a MongoDB statefulset.
217
- --postgresql Initializes the cluster with a PostgreSQL statefulset.
218
- --mongodb4 Initializes the cluster with a MongoDB 4.4 service.
219
- --valkey Initializes the cluster with a Valkey service.
220
- --contour Initializes the cluster with Project Contour base
221
- HTTPProxy and Envoy.
222
- --cert-manager Initializes the cluster with a Let's Encrypt production
223
- ClusterIssuer.
224
- --dedicated-gpu Initializes the cluster with dedicated GPU base
225
- resources and environment settings.
226
- --info Retrieves information about all deployed Kubernetes
227
- objects.
228
- --full Initializes the cluster with all available statefulsets
229
- and services.
230
- --ns-use <ns-name> Switches the current Kubernetes context to the specified
231
- namespace.
232
- --kubeadm Initializes the cluster using kubeadm for control plane
233
- management.
234
- --dev Initializes a development-specific cluster
235
- configuration.
236
- --list-pods Displays detailed information about all pods.
237
- --info-capacity Displays the current total machine capacity information.
238
- --info-capacity-pod Displays the current machine capacity information per
239
- pod.
240
- --pull-image Sets an optional associated image to pull during
241
- initialization.
242
- --init-host Installs necessary Kubernetes node CLI tools (e.g.,
243
- kind, kubeadm, docker, podman, helm).
244
- --uninstall-host Uninstalls all host components installed by init-host.
245
- --config Sets the base Kubernetes node configuration.
246
- --worker Sets the context for a worker node.
247
- --chown Sets the appropriate ownership for Kubernetes kubeconfig
248
- files.
249
- --k3s Initializes the cluster using K3s (Lightweight
250
- Kubernetes).
251
- -h, --help display help for command
212
+ --reset Deletes all clusters and prunes all related data and
213
+ caches.
214
+ --mariadb Initializes the cluster with a MariaDB statefulset.
215
+ --mysql Initializes the cluster with a MySQL statefulset.
216
+ --mongodb Initializes the cluster with a MongoDB statefulset.
217
+ --mongo-db-host <host> Set custom mongo db host
218
+ --postgresql Initializes the cluster with a PostgreSQL
219
+ statefulset.
220
+ --mongodb4 Initializes the cluster with a MongoDB 4.4 service.
221
+ --valkey Initializes the cluster with a Valkey service.
222
+ --contour Initializes the cluster with Project Contour base
223
+ HTTPProxy and Envoy.
224
+ --cert-manager Initializes the cluster with a Let's Encrypt
225
+ production ClusterIssuer.
226
+ --dedicated-gpu Initializes the cluster with dedicated GPU base
227
+ resources and environment settings.
228
+ --info Retrieves information about all deployed Kubernetes
229
+ objects.
230
+ --full Initializes the cluster with all available
231
+ statefulsets and services.
232
+ --ns-use <ns-name> Switches the current Kubernetes context to the
233
+ specified namespace.
234
+ --kubeadm Initializes the cluster using kubeadm for control
235
+ plane management.
236
+ --dev Initializes a development-specific cluster
237
+ configuration.
238
+ --list-pods Displays detailed information about all pods.
239
+ --info-capacity Displays the current total machine capacity
240
+ information.
241
+ --info-capacity-pod Displays the current machine capacity information per
242
+ pod.
243
+ --pull-image Sets an optional associated image to pull during
244
+ initialization.
245
+ --init-host Installs necessary Kubernetes node CLI tools (e.g.,
246
+ kind, kubeadm, docker, podman, helm).
247
+ --uninstall-host Uninstalls all host components installed by
248
+ init-host.
249
+ --config Sets the base Kubernetes node configuration.
250
+ --worker Sets the context for a worker node.
251
+ --chown Sets the appropriate ownership for Kubernetes
252
+ kubeconfig files.
253
+ --k3s Initializes the cluster using K3s (Lightweight
254
+ Kubernetes).
255
+ -h, --help display help for command
252
256
 
253
257
  ```
254
258
 
@@ -554,7 +558,7 @@ Options:
554
558
  Runs a script from the specified path.
555
559
 
556
560
  Arguments:
557
- runner-id The runner ID to run. Options: spark-template, rmi, kill, secret, gpu-env, tf-gpu-test, ide, monitor, tf-vae-test, deploy-job.
561
+ runner-id The runner ID to run. Options: spark-template, rmi, kill, secret, gpu-env, tf-gpu-test, dev-cluster, cyberia-ide, engine-ide, ide, monitor, db-client, cluster, deploy, tf-vae-test, deploy-job.
558
562
  path The absolute or relative directory path where the script is located.
559
563
 
560
564
  Options:
@@ -564,6 +568,7 @@ Options:
564
568
  --pod-name <pod-name> Optional: Specifies the pod name for test execution.
565
569
  --volume-host-path <volume-host-path> Optional: Specifies the volume host path for test execution.
566
570
  --volume-mount-path <volume-mount-path> Optional: Specifies the volume mount path for test execution.
571
+ --volume-type <volume-type> Optional: Specifies the volume type for test execution.
567
572
  --image-name <image-name> Optional: Specifies the image name for test execution.
568
573
  --container-name <container-name> Optional: Specifies the container name for test execution.
569
574
  --namespace <namespace> Optional: Specifies the namespace for test execution.
@@ -58,7 +58,7 @@ services:
58
58
  cpus: '0.25'
59
59
  memory: 20M
60
60
  labels: # labels in Compose file instead of Dockerfile
61
- engine.version: '2.8.841'
61
+ engine.version: '2.8.844'
62
62
  networks:
63
63
  - load-balancer
64
64
 
@@ -17,7 +17,7 @@ spec:
17
17
  spec:
18
18
  containers:
19
19
  - name: dd-template-development-blue
20
- image: localhost/rockylinux9-underpost:v2.8.841
20
+ image: localhost/rockylinux9-underpost:v2.8.844
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-template-development-green
103
- image: localhost/rockylinux9-underpost:v2.8.841
103
+ image: localhost/rockylinux9-underpost:v2.8.844
104
104
  # resources:
105
105
  # requests:
106
106
  # memory: "124Ki"
@@ -5,7 +5,7 @@ sudo lspci -nnk | egrep -i 'vga|3d' -A3
5
5
  lsmod | egrep 'nvidia|nouveau|amdgpu' || true
6
6
 
7
7
  # if exists nvidia tool
8
- nvidia-smi 2>/dev/null || echo "nvidia-smi no disponible / driver no cargado"
8
+ nvidia-smi 2>/dev/null || echo "nvidia-smi not found"
9
9
 
10
10
  # kernel related errors
11
11
  sudo dmesg | egrep -i 'nvidia|nouveau|amdgpu' --color=auto
package/package.json CHANGED
@@ -2,16 +2,17 @@
2
2
  "type": "module",
3
3
  "main": "src/index.js",
4
4
  "name": "underpost",
5
- "version": "2.8.841",
5
+ "version": "2.8.844",
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
+ "build": "node bin/deploy build-full-client",
9
10
  "test": "env-cmd -f .env.test c8 mocha",
10
11
  "pm2": "env-cmd -f .env.production pm2 start src/server.js --node-args=\"--max-old-space-size=8192\" --name engine",
11
12
  "dev": "env-cmd -f .env.development node src/client.dev default",
12
13
  "dev-img": "env-cmd -f .env.development node src/server",
13
14
  "prod-img": "env-cmd -f .env.production node src/server",
14
- "monitor": "pm2 start bin/deploy.js --name monitor -- monitor",
15
+ "monitor": "pm2 start src/monitor.js --name monitor -- dd production",
15
16
  "dev-api": "env-cmd -f .env.development nodemon --watch src --ignore src/client src/api",
16
17
  "dev-client": "env-cmd -f .env.development node src/client.dev",
17
18
  "proxy": "node src/proxy proxy",
@@ -23,8 +24,7 @@
23
24
  "docker:start": "docker-compose up",
24
25
  "prettier": "prettier --write .",
25
26
  "fix": "npm audit fix --force && npm audit",
26
- "changelog": "auto-changelog",
27
- "build": "node bin/deploy build-full-client"
27
+ "changelog": "auto-changelog"
28
28
  },
29
29
  "bin": {
30
30
  "underpost": "bin/index.js"
@@ -99,7 +99,6 @@
99
99
  "peer": "^1.0.2",
100
100
  "peerjs": "^1.5.2",
101
101
  "pixi.js": "7.4.2",
102
- "plantuml": "^0.0.2",
103
102
  "prom-client": "^15.1.2",
104
103
  "public-ip": "^6.0.1",
105
104
  "read": "^2.1.0",
@@ -1,8 +1,9 @@
1
- import { authMiddleware } from '../../server/auth.js';
1
+ import { authMiddleware, hashPassword } from '../../server/auth.js';
2
2
  import fs from 'fs-extra';
3
3
  import { loggerFactory } from '../../server/logger.js';
4
4
  import { UserController } from './user.controller.js';
5
5
  import express from 'express';
6
+ import { DataBaseProvider } from '../../db/DataBaseProvider.js';
6
7
 
7
8
  const logger = loggerFactory(import.meta);
8
9
 
@@ -10,6 +11,28 @@ const UserRouter = (options) => {
10
11
  const router = express.Router();
11
12
 
12
13
  (async () => {
14
+ const models = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.models;
15
+ if (models.User) {
16
+ try {
17
+ const adminUser = await models.User.findOne({ role: 'admin' });
18
+ if (!adminUser) {
19
+ const defaultPassword = process.env.DEFAULT_ADMIN_PASSWORD || 'changethis';
20
+ const hashedPassword = hashPassword(defaultPassword);
21
+
22
+ const result = await models.User.create({
23
+ username: 'admin',
24
+ email: process.env.DEFAULT_ADMIN_EMAIL || 'admin@' + options.host,
25
+ password: hashedPassword,
26
+ role: 'admin',
27
+ emailConfirmed: true,
28
+ publicKey: [],
29
+ });
30
+ logger.warn('Default admin user created. Please change the default password immediately!', result._doc);
31
+ }
32
+ } catch (error) {
33
+ logger.error('Error checking/creating admin user:', error);
34
+ }
35
+ }
13
36
  options.png = {
14
37
  buffer: {
15
38
  'invalid-token': fs.readFileSync(`./src/client/public/default/assets/mailer/api-user-invalid-token.png`),
@@ -19,6 +19,7 @@ class UnderpostCluster {
19
19
  * @param {object} [options] - Configuration options for cluster initialization.
20
20
  * @param {boolean} [options.mongodb=false] - Deploy MongoDB.
21
21
  * @param {boolean} [options.mongodb4=false] - Deploy MongoDB 4.4.
22
+ * @param {String} [options.mongoDbHost=''] - Set custom mongo db host
22
23
  * @param {boolean} [options.mariadb=false] - Deploy MariaDB.
23
24
  * @param {boolean} [options.mysql=false] - Deploy MySQL.
24
25
  * @param {boolean} [options.postgresql=false] - Deploy PostgreSQL.
@@ -48,6 +49,7 @@ class UnderpostCluster {
48
49
  options = {
49
50
  mongodb: false,
50
51
  mongodb4: false,
52
+ mongoDbHost: '',
51
53
  mariadb: false,
52
54
  mysql: false,
53
55
  postgresql: false,
@@ -271,6 +273,7 @@ class UnderpostCluster {
271
273
  }
272
274
  shellExec(`kubectl delete statefulset valkey-service --ignore-not-found`);
273
275
  shellExec(`kubectl apply -k ${underpostRoot}/manifests/valkey`);
276
+ await UnderpostTest.API.statusMonitor('valkey-service', 'Running', 'pods', 1000, 60);
274
277
  }
275
278
  if (options.full === true || options.mariadb === true) {
276
279
  shellExec(
@@ -288,9 +291,7 @@ class UnderpostCluster {
288
291
  // For kubeadm/k3s, ensure it's available for containerd
289
292
  shellExec(`sudo crictl pull mariadb:latest`);
290
293
  }
291
- if (options.kubeadm === true)
292
- // This storage class is specific to kubeadm setup
293
- shellExec(`kubectl apply -f ${underpostRoot}/manifests/mariadb/storage-class.yaml`);
294
+ shellExec(`kubectl apply -f ${underpostRoot}/manifests/mariadb/storage-class.yaml`);
294
295
  shellExec(`kubectl apply -k ${underpostRoot}/manifests/mariadb`);
295
296
  }
296
297
  if (options.full === true || options.mysql === true) {
@@ -334,9 +335,10 @@ class UnderpostCluster {
334
335
  const successInstance = await UnderpostTest.API.statusMonitor(deploymentName);
335
336
 
336
337
  if (successInstance) {
338
+ if (!options.mongoDbHost) options.mongoDbHost = 'mongodb-service';
337
339
  const mongoConfig = {
338
340
  _id: 'rs0',
339
- members: [{ _id: 0, host: 'mongodb-service:27017' }],
341
+ members: [{ _id: 0, host: `${options.mongoDbHost}:27017` }],
340
342
  };
341
343
 
342
344
  const [pod] = UnderpostDeploy.API.get(deploymentName);
@@ -363,19 +365,26 @@ class UnderpostCluster {
363
365
  `sudo kubectl create secret generic mongodb-secret --from-file=username=/home/dd/engine/engine-private/mongodb-username --from-file=password=/home/dd/engine/engine-private/mongodb-password --dry-run=client -o yaml | kubectl apply -f -`,
364
366
  );
365
367
  shellExec(`kubectl delete statefulset mongodb --ignore-not-found`);
366
- if (options.kubeadm === true)
367
- // This storage class is specific to kubeadm setup
368
- shellExec(`kubectl apply -f ${underpostRoot}/manifests/mongodb/storage-class.yaml`);
368
+ shellExec(`kubectl apply -f ${underpostRoot}/manifests/mongodb/storage-class.yaml`);
369
369
  shellExec(`kubectl apply -k ${underpostRoot}/manifests/mongodb`);
370
370
 
371
- const successInstance = await UnderpostTest.API.statusMonitor('mongodb-1');
371
+ const successInstance = await UnderpostTest.API.statusMonitor('mongodb-0', 'Running', 'pods', 1000, 60 * 10);
372
372
 
373
373
  if (successInstance) {
374
+ if (!options.mongoDbHost) options.mongoDbHost = 'mongodb-service';
374
375
  const mongoConfig = {
375
376
  _id: 'rs0',
376
377
  members: [
377
- { _id: 0, host: 'mongodb-0.mongodb-service:27017', priority: 1 },
378
- { _id: 1, host: 'mongodb-1.mongodb-service:27017', priority: 1 },
378
+ {
379
+ _id: 0,
380
+ host: `${options.mongoDbHost === 'mongodb-service' ? 'mongodb-0.' : ''}${options.mongoDbHost}:27017`,
381
+ priority: 1,
382
+ },
383
+ // {
384
+ // _id: 1,
385
+ // host: `${options.mongoDbHost === 'mongodb-service' ? 'mongodb-1.' : ''}${options.mongoDbHost}:27017`,
386
+ // priority: 1,
387
+ // },
379
388
  ],
380
389
  };
381
390
 
package/src/cli/deploy.js CHANGED
@@ -528,6 +528,25 @@ node bin/deploy build-full-client ${deployId}
528
528
  }).trim(),
529
529
  );
530
530
  },
531
+ checkDeploymentReadyStatus(deployId, env, traffic) {
532
+ const cmd = `underpost config get container-status`;
533
+ const pods = UnderpostDeploy.API.get(`${deployId}-${env}-${traffic}`);
534
+ const readyPods = [];
535
+ const notReadyPods = [];
536
+ for (const pod of pods) {
537
+ const { NAME } = pod;
538
+ if (
539
+ shellExec(`sudo kubectl exec -i ${NAME} -- sh -c "${cmd}"`, { stdout: true }).match(
540
+ `${deployId}-${env}-running-deployment`,
541
+ )
542
+ ) {
543
+ readyPods.push(pod);
544
+ } else {
545
+ notReadyPods.push(pod);
546
+ }
547
+ }
548
+ return { ready: notReadyPods.length === 0, notReadyPods, readyPods };
549
+ },
531
550
  };
532
551
  }
533
552