@underpostnet/cyberia 3.2.90 → 3.3.73
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/.dockerignore +1 -0
- package/.env.example +16 -0
- package/.github/workflows/coverall.cyberia.ci.yml +107 -0
- package/.github/workflows/cyberia-client.cd.yml +6 -18
- package/.github/workflows/cyberia-server.cd.yml +6 -18
- package/.github/workflows/docker-image.cyberia-client.ci.yml +8 -5
- package/.github/workflows/docker-image.cyberia-client.dev.ci.yml +8 -3
- package/.github/workflows/docker-image.cyberia-server.ci.yml +8 -5
- package/.github/workflows/docker-image.cyberia-server.dev.ci.yml +8 -5
- package/.github/workflows/docker-image.engine-cyberia.ci.yml +15 -1
- package/.github/workflows/docker-image.engine-cyberia.dev.ci.yml +15 -1
- package/.github/workflows/engine-cyberia.cd.yml +6 -78
- package/.github/workflows/engine-cyberia.ci.yml +4 -5
- package/.github/workflows/ghpkg.ci.yml +42 -21
- package/.github/workflows/hardhat.ci.yml +12 -11
- package/.github/workflows/npmpkg.ci.yml +17 -15
- package/.github/workflows/pwa-microservices-template-page.cd.yml +1 -16
- package/.github/workflows/pwa-microservices-template-test.ci.yml +2 -2
- package/.github/workflows/release.cd.yml +2 -9
- package/.prettierignore +1 -0
- package/AGENTS.md +47 -0
- package/CHANGELOG.md +581 -2417
- package/CLI-HELP.md +416 -127
- package/Dockerfile +25 -9
- package/Dockerfile.dev +25 -9
- package/Dockerfile.test +4 -4
- package/README.md +21 -1
- package/bin/build.js +70 -43
- package/bin/build.template.js +8 -3
- package/bin/cyberia.js +372 -135
- package/bin/deploy.js +18 -104
- package/bin/index.js +372 -135
- package/compose.env +16 -0
- package/conf.js +93 -4
- package/deploy/cyberia-client/deploy.sh +47 -0
- package/deploy/cyberia-client/package.sh +18 -0
- package/deploy/cyberia-client/state.sh +14 -0
- package/deploy/cyberia-server/deploy.sh +47 -0
- package/deploy/cyberia-server/package.sh +18 -0
- package/deploy/cyberia-server/state.sh +14 -0
- package/deploy/dd-cyberia/deploy.sh +22 -0
- package/deploy/dd-cyberia/init.sh +55 -0
- package/deploy/dd-cyberia/package.sh +17 -0
- package/deploy/dd-cyberia/state.sh +14 -0
- package/deploy/dd-cyberia/sync-deploy.sh +116 -0
- package/deploy/lib/github-actions-logging.sh +594 -0
- package/deploy/lib/host.sh +185 -0
- package/deploy/lib/state.sh +62 -0
- package/deploy/pwa-microservices-template/deploy.sh +45 -0
- package/deploy/release/deploy.sh +32 -0
- package/deployment.yaml +7 -2
- package/docker-compose.yml +31 -37
- package/examples/static-page/README.md +19 -19
- package/examples/static-page/ssr-components/CustomPage.js +2 -2
- package/hardhat/hardhat.config.js +1 -6
- package/hardhat/package-lock.json +104 -43
- package/hardhat/package.json +3 -3
- package/manifests/alertmanager/deployment.yaml +81 -0
- package/manifests/blackbox-exporter/deployment.yaml +75 -0
- package/manifests/cronjobs/dd-cron/dd-cron-backup.yaml +36 -7
- package/manifests/cronjobs/dd-cron/dd-cron-vultr.yaml +77 -0
- package/manifests/deployment/dd-cyberia-development/deployment.yaml +7 -2
- package/manifests/deployment/dd-default-development/deployment.yaml +2 -2
- package/manifests/grafana/deployment.yaml +26 -7
- package/manifests/grafana/kustomization.yaml +1 -0
- package/manifests/grafana/service.yaml +6 -1
- package/manifests/mariadb/pv.yaml +1 -0
- package/manifests/mongodb/statefulset.yaml +9 -2
- package/manifests/mysql/pv-pvc.yaml +14 -1
- package/manifests/postgresql/pv.yaml +12 -1
- package/manifests/postgresql/pvc.yaml +1 -0
- package/manifests/prometheus/deployment.yaml +18 -22
- package/package.json +83 -10
- package/scripts/audit-selinux.sh +64 -0
- package/scripts/event-monitor.sh +56 -0
- package/scripts/gpu-diag.sh +0 -0
- package/scripts/ip-info.sh +0 -0
- package/scripts/k3s-node-setup.sh +30 -14
- package/scripts/kubeadm-node-setup.sh +40 -31
- package/scripts/lxd-vm-setup.sh +0 -0
- package/scripts/maas-nat-firewalld.sh +0 -0
- package/scripts/maas-setup.sh +8 -8
- package/scripts/nat-iptables.sh +2 -0
- package/scripts/rhel-grpc-setup.sh +0 -0
- package/scripts/rocky-kickstart.sh +25 -9
- package/scripts/selinux-normalize.sh +907 -0
- package/scripts/shutdown-machine.sh +843 -0
- package/scripts/test-monitor.sh +3 -3
- package/src/api/atlas-sprite-sheet/atlas-sprite-sheet.controller.js +1 -1
- package/src/api/atlas-sprite-sheet/atlas-sprite-sheet.router.js +2 -2
- package/src/api/atlas-sprite-sheet/atlas-sprite-sheet.service.js +2 -2
- package/src/api/core/core.controller.js +1 -1
- package/src/api/core/core.router.js +2 -2
- package/src/api/core/core.service.js +2 -2
- package/src/api/crypto/crypto.controller.js +1 -1
- package/src/api/crypto/crypto.service.js +1 -1
- package/src/api/cyberia-action/cyberia-action.controller.js +1 -1
- package/src/api/cyberia-action/cyberia-action.router.js +1 -1
- package/src/api/cyberia-action/cyberia-action.service.js +2 -2
- package/src/api/cyberia-client-hints/cyberia-client-hints.controller.js +1 -1
- package/src/api/cyberia-client-hints/cyberia-client-hints.router.js +1 -1
- package/src/api/cyberia-client-hints/cyberia-client-hints.service.js +2 -2
- package/src/api/cyberia-dialogue/cyberia-dialogue.controller.js +1 -1
- package/src/api/cyberia-dialogue/cyberia-dialogue.router.js +1 -1
- package/src/api/cyberia-dialogue/cyberia-dialogue.service.js +2 -2
- package/src/api/cyberia-entity/cyberia-entity.controller.js +1 -1
- package/src/api/cyberia-entity/cyberia-entity.router.js +1 -1
- package/src/api/cyberia-entity/cyberia-entity.service.js +2 -2
- package/src/api/cyberia-entity-type-default/cyberia-entity-type-default.controller.js +1 -1
- package/src/api/cyberia-entity-type-default/cyberia-entity-type-default.router.js +1 -1
- package/src/api/cyberia-entity-type-default/cyberia-entity-type-default.service.js +2 -2
- package/src/api/cyberia-instance/cyberia-fallback-capture.js +466 -0
- package/src/api/cyberia-instance/cyberia-fallback-default-items.js +63 -0
- package/src/api/cyberia-instance/cyberia-fallback-world.js +16 -1
- package/src/api/cyberia-instance/cyberia-instance-map.service.js +1 -1
- package/src/api/cyberia-instance/cyberia-instance.controller.js +4 -1
- package/src/api/cyberia-instance/cyberia-instance.router.js +15 -2
- package/src/api/cyberia-instance/cyberia-instance.service.js +45 -2
- package/src/api/cyberia-instance-conf/cyberia-instance-conf.controller.js +1 -1
- package/src/api/cyberia-instance-conf/cyberia-instance-conf.model.js +1 -0
- package/src/api/cyberia-instance-conf/cyberia-instance-conf.router.js +1 -1
- package/src/api/cyberia-instance-conf/cyberia-instance-conf.service.js +2 -2
- package/src/api/cyberia-map/cyberia-map.controller.js +1 -1
- package/src/api/cyberia-map/cyberia-map.router.js +1 -1
- package/src/api/cyberia-map/cyberia-map.service.js +2 -2
- package/src/api/cyberia-quest/cyberia-quest.controller.js +1 -1
- package/src/api/cyberia-quest/cyberia-quest.router.js +1 -1
- package/src/api/cyberia-quest/cyberia-quest.service.js +2 -2
- package/src/api/cyberia-quest-progress/cyberia-quest-progress.controller.js +1 -1
- package/src/api/cyberia-quest-progress/cyberia-quest-progress.router.js +1 -1
- package/src/api/cyberia-quest-progress/cyberia-quest-progress.service.js +2 -2
- package/src/api/cyberia-saga/cyberia-saga.controller.js +1 -1
- package/src/api/cyberia-saga/cyberia-saga.router.js +1 -1
- package/src/api/cyberia-saga/cyberia-saga.service.js +2 -2
- package/src/api/cyberia-server-defaults/cyberia-server-defaults.js +16 -29
- package/src/api/cyberia-skill/cyberia-skill.controller.js +1 -1
- package/src/api/cyberia-skill/cyberia-skill.router.js +1 -1
- package/src/api/cyberia-skill/cyberia-skill.service.js +2 -2
- package/src/api/default/default.controller.js +1 -1
- package/src/api/default/default.router.js +1 -1
- package/src/api/default/default.service.js +2 -2
- package/src/api/document/document.controller.js +1 -1
- package/src/api/document/document.router.js +1 -1
- package/src/api/document/document.service.js +2 -2
- package/src/api/file/file.controller.js +1 -1
- package/src/api/file/file.router.js +1 -1
- package/src/api/file/file.service.js +2 -2
- package/src/api/instance/instance.controller.js +1 -1
- package/src/api/instance/instance.router.js +1 -1
- package/src/api/instance/instance.service.js +2 -2
- package/src/api/ipfs/ipfs.controller.js +1 -1
- package/src/api/ipfs/ipfs.router.js +2 -2
- package/src/api/ipfs/ipfs.service.js +2 -2
- package/src/api/object-layer/object-layer.controller.js +1 -1
- package/src/api/object-layer/object-layer.model.js +204 -3
- package/src/api/object-layer/object-layer.router.js +2 -2
- package/src/api/object-layer/object-layer.service.js +4 -17
- package/src/api/object-layer-render-frames/object-layer-render-frames.controller.js +1 -1
- package/src/api/object-layer-render-frames/object-layer-render-frames.router.js +1 -1
- package/src/api/object-layer-render-frames/object-layer-render-frames.service.js +2 -2
- package/src/api/test/test.controller.js +1 -1
- package/src/api/test/test.service.js +1 -1
- package/src/api/user/guest.service.js +3 -3
- package/src/api/user/user.controller.js +1 -1
- package/src/api/user/user.router.js +2 -2
- package/src/api/user/user.service.js +4 -4
- package/src/api.js +5 -9
- package/src/cli/app.js +391 -0
- package/src/cli/baremetal.js +30 -36
- package/src/cli/client.js +306 -0
- package/src/cli/cloud-init.js +3 -3
- package/src/cli/cluster.js +242 -135
- package/src/cli/db.js +126 -67
- package/src/cli/deploy.js +158 -60
- package/src/cli/docker-compose.js +5 -5
- package/src/cli/domains.js +184 -0
- package/src/cli/dotenv-store.js +143 -0
- package/src/cli/event.js +2281 -0
- package/src/cli/fs.js +3 -3
- package/src/cli/host.js +672 -0
- package/src/cli/image.js +4 -7
- package/src/cli/index.js +426 -134
- package/src/cli/ipfs.js +34 -30
- package/src/cli/kickstart.js +1 -1
- package/src/cli/kubectl.js +218 -41
- package/src/cli/lxd.js +3 -3
- package/src/cli/monitor.js +1359 -26
- package/src/cli/package.js +90 -0
- package/src/cli/release.js +73 -34
- package/src/cli/repository.js +564 -367
- package/src/cli/run.js +362 -654
- package/src/cli/secrets.js +2158 -964
- package/src/cli/ssh.js +651 -331
- package/src/cli/state.js +394 -0
- package/src/cli/static.js +2 -2
- package/src/cli/system.js +26 -13
- package/src/cli/test.js +199 -125
- package/src/cli/vultr.js +623 -0
- package/src/cli/wireguard.js +2930 -0
- package/src/client/components/core/CalendarCore.js +53 -96
- package/src/client/components/core/Docs.js +258 -211
- package/src/client/components/core/FileExplorer.js +0 -21
- package/src/client/components/core/PanelForm.js +4 -4
- package/src/client/components/core/Repository.js +56 -0
- package/src/client/components/core/Translate.js +7 -0
- package/src/client/components/core/{FullScreen.js → ViewModeController.js} +42 -39
- package/src/client/components/core/Wallet.js +0 -11
- package/src/client/components/core/Worker.js +7 -1
- package/src/client/components/cryptokoyn/SettingsCryptokoyn.js +2 -2
- package/src/client/components/cyberia/FallbackWorldEngineCyberia.js +368 -0
- package/src/client/components/cyberia-portal/AppShellCyberiaPortal.js +35 -1
- package/src/client/components/cyberia-portal/RouterCyberiaPortal.js +4 -0
- package/src/client/components/cyberia-portal/SettingsCyberiaPortal.js +2 -2
- package/src/client/components/cyberia-portal/TranslateCyberiaPortal.js +4 -0
- package/src/client/components/default/AppShellDefault.js +1 -1
- package/src/client/components/default/SettingsDefault.js +2 -2
- package/src/client/components/itemledger/SettingsItemledger.js +2 -2
- package/src/client/components/underpost/AppShellUnderpost.js +3 -2
- package/src/client/components/underpost/SettingsUnderpost.js +2 -2
- package/src/client/public/cyberia-docs/ARCHITECTURE.md +17 -3
- package/src/client/public/cyberia-docs/CYBERIA-CLI.md +32 -5
- package/src/client/public/cyberia-docs/CYBERIA-SERVER.md +1 -1
- package/src/client/public/cyberia-docs/CYBERIA.md +21 -1
- package/src/client/public/cyberia-docs/HARDHAT-MODULE.md +23 -6
- package/src/client/public/cyberia-docs/ROADMAP.md +1 -1
- package/src/client/public/cyberia-docs/WHITE-PAPER.md +1 -1
- package/src/client/public/default/android-chrome-144x144.png +0 -0
- package/src/client/public/default/android-chrome-192x192.png +0 -0
- package/src/client/public/default/android-chrome-256x256.png +0 -0
- package/src/client/public/default/android-chrome-36x36.png +0 -0
- package/src/client/public/default/android-chrome-384x384.png +0 -0
- package/src/client/public/default/android-chrome-48x48.png +0 -0
- package/src/client/public/default/android-chrome-512x512.png +0 -0
- package/src/client/public/default/android-chrome-72x72.png +0 -0
- package/src/client/public/default/android-chrome-96x96.png +0 -0
- package/src/client/public/default/apple-touch-icon-1024x1024.png +0 -0
- package/src/client/public/default/apple-touch-icon-114x114.png +0 -0
- package/src/client/public/default/apple-touch-icon-120x120.png +0 -0
- package/src/client/public/default/apple-touch-icon-144x144.png +0 -0
- package/src/client/public/default/apple-touch-icon-152x152.png +0 -0
- package/src/client/public/default/apple-touch-icon-167x167.png +0 -0
- package/src/client/public/default/apple-touch-icon-180x180.png +0 -0
- package/src/client/public/default/apple-touch-icon-57x57.png +0 -0
- package/src/client/public/default/apple-touch-icon-60x60.png +0 -0
- package/src/client/public/default/apple-touch-icon-72x72.png +0 -0
- package/src/client/public/default/apple-touch-icon-76x76.png +0 -0
- package/src/client/public/default/apple-touch-icon-precomposed.png +0 -0
- package/src/client/public/default/apple-touch-icon.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1125x2436.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1136x640.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1170x2532.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1179x2556.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1242x2208.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1242x2688.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1284x2778.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1290x2796.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1334x750.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1488x2266.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1536x2048.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1620x2160.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1640x2160.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1668x2224.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1668x2388.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1792x828.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2048x1536.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2048x2732.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2160x1620.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2160x1640.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2208x1242.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2224x1668.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2266x1488.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2388x1668.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2436x1125.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2532x1170.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2556x1179.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2688x1242.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2732x2048.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2778x1284.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2796x1290.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-640x1136.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-750x1334.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-828x1792.png +0 -0
- package/src/client/public/default/assets/background/white.jpg +0 -0
- package/src/client/public/default/browserconfig.xml +1 -1
- package/src/client/public/default/favicon-16x16.png +0 -0
- package/src/client/public/default/favicon-32x32.png +0 -0
- package/src/client/public/default/favicon-48x48.png +0 -0
- package/src/client/public/default/favicon.ico +0 -0
- package/src/client/public/default/manifest.webmanifest +5 -5
- package/src/client/public/default/mstile-144x144.png +0 -0
- package/src/client/public/default/mstile-150x150.png +0 -0
- package/src/client/public/default/mstile-310x150.png +0 -0
- package/src/client/public/default/mstile-310x310.png +0 -0
- package/src/client/public/default/mstile-70x70.png +0 -0
- package/src/client/public/default/yandex-browser-50x50.png +0 -0
- package/src/client/public/default/yandex-browser-manifest.json +1 -1
- package/src/client/services/cyberia-instance/cyberia-instance.service.js +40 -0
- package/src/client/services/object-layer/object-layer.management.js +4 -4
- package/src/client/ssr/RootDocument.js +1 -1
- package/src/client/ssr/body/404.js +1 -1
- package/src/client/ssr/body/500.js +1 -1
- package/src/client/ssr/body/CacheControl.js +1 -1
- package/src/client/ssr/body/CyberiaDefaultSplashScreen.js +1 -1
- package/src/client/ssr/body/DefaultSplashScreen.js +1 -1
- package/src/client/ssr/body/SwaggerDarkMode.js +1 -1
- package/src/client/ssr/body/UnderpostDefaultSplashScreen.js +1 -1
- package/src/client/ssr/head/CryptokoynScripts.js +1 -1
- package/src/client/ssr/head/Css.js +1 -1
- package/src/client/ssr/head/CyberiaPortalScripts.js +1 -1
- package/src/client/ssr/head/DefaultScripts.js +1 -1
- package/src/client/ssr/head/ItemledgerScripts.js +1 -1
- package/src/client/ssr/head/Microdata.js +1 -1
- package/src/client/ssr/head/Production.js +1 -1
- package/src/client/ssr/head/Pwa.js +1 -1
- package/src/client/ssr/head/PwaItemledger.js +1 -1
- package/src/client/ssr/head/Seo.js +1 -1
- package/src/client/ssr/head/UnderpostScripts.js +1 -1
- package/src/client/ssr/mailer/DefaultRecoverEmail.js +1 -1
- package/src/client/ssr/mailer/DefaultVerifyEmail.js +1 -1
- package/src/client/ssr/views/Cyberia404.js +7 -5
- package/src/client/ssr/views/CyberiaServerMetrics.js +1 -1
- package/src/client/ssr/views/Maintenance.js +1 -1
- package/src/client/ssr/views/NoNetworkConnection.js +1 -1
- package/src/client/ssr/views/Test.js +1 -1
- package/src/client/sw/core.sw.js +20 -14
- package/src/client-builder/client-build-docs.js +61 -46
- package/src/client-builder/client-build-live.js +2 -2
- package/src/client-builder/client-build.js +58 -44
- package/src/client-builder/client-dev-server.js +3 -3
- package/src/client-builder/client-icons.js +2 -2
- package/src/client-builder/ssr.js +3 -3
- package/src/client.build.js +3 -6
- package/src/client.dev.js +3 -6
- package/src/db/DataBaseProvider.js +186 -3
- package/src/db/mariadb/MariaDB.js +3 -2
- package/src/db/mongo/MongoBootstrap.js +273 -101
- package/src/db/mongo/MongooseDB.js +11 -8
- package/src/{server/valkey.js → db/valkey/Valkey.js} +5 -4
- package/src/grpc/cyberia/grpc-server.js +1 -1
- package/src/index.js +103 -23
- package/src/mailer/EmailRender.js +2 -2
- package/src/mailer/MailerInterceptor.js +87 -0
- package/src/mailer/MailerProvider.js +50 -6
- package/src/projects/cyberia/atlas-sprite-sheet-generator.js +1 -1
- package/src/projects/cyberia/besu-genesis-generator.js +3 -3
- package/src/projects/cyberia/catalog-cyberia.js +54 -6
- package/src/projects/cyberia/gemini-client.js +1 -1
- package/src/projects/cyberia/generate-saga.js +15 -24
- package/src/projects/cyberia/hot-reload-trigger.js +1 -1
- package/src/projects/cyberia/instance-data.js +22 -3
- package/src/projects/cyberia/ipfs-client.js +4 -4
- package/src/projects/cyberia/map-preview-generator.js +1 -1
- package/src/projects/cyberia/object-layer.js +12 -22
- package/src/projects/cyberia/semantic-layer-generator.js +1 -1
- package/src/projects/underpost/catalog-underpost.js +13 -2
- package/src/proxy.js +4 -7
- package/src/runtime/cyberia-client/Dockerfile +9 -4
- package/src/runtime/cyberia-client/Dockerfile.dev +8 -2
- package/src/runtime/cyberia-server/Dockerfile +9 -4
- package/src/runtime/cyberia-server/Dockerfile.dev +8 -2
- package/src/runtime/engine-cyberia/Dockerfile +25 -9
- package/src/runtime/engine-cyberia/Dockerfile.dev +25 -9
- package/src/runtime/engine-cyberia/Dockerfile.test +4 -4
- package/src/runtime/engine-cyberia/compose.env +16 -0
- package/src/runtime/engine-cyberia/docker-compose.yml +31 -37
- package/src/runtime/express/Express.js +32 -27
- package/src/runtime/lampp/Lampp.js +22 -70
- package/src/runtime/nginx/Nginx.js +1 -1
- package/src/runtime/wp/Wp.js +16 -48
- package/src/server/{catalog.js → build/catalog.js} +15 -5
- package/src/server/build/coverage.js +117 -0
- package/src/server/build/execution.js +402 -0
- package/src/server/build/package.js +465 -0
- package/src/server/build/testing.js +528 -0
- package/src/server/{dns.js → network/dns.js} +241 -14
- package/src/server/network/forward-proxy.js +541 -0
- package/src/server/{middlewares.js → network/middlewares.js} +59 -4
- package/src/server/network/node-capability.js +98 -0
- package/src/server/{peer.js → network/peer.js} +3 -3
- package/src/server/{proxy.js → network/proxy.js} +7 -13
- package/src/server/network/router.js +356 -0
- package/src/server/{tls.js → network/tls.js} +2 -2
- package/src/server/network/underpost-compression.js +186 -0
- package/src/server/{underpost-gateway.js → network/underpost-gateway.js} +26 -16
- package/src/server/{underpost-ingress.js → network/underpost-ingress.js} +19 -3
- package/src/server/{cri.js → ops/cri.js} +2 -2
- package/src/server/ops/cron.js +949 -0
- package/src/server/ops/event-notification.js +284 -0
- package/src/server/{logger.js → ops/logger.js} +108 -23
- package/src/server/ops/monitoring.js +1724 -0
- package/src/server/ops/systemd.js +259 -0
- package/src/server/{conf.js → runtime/conf.js} +521 -520
- package/src/server/runtime/config-scope.js +215 -0
- package/src/server/runtime/environment.js +149 -0
- package/src/server/{process.js → runtime/process.js} +153 -13
- package/src/server/{runtime-status.js → runtime/runtime-status.js} +155 -16
- package/src/server/{runtime.js → runtime/runtime.js} +12 -8
- package/src/server/{start.js → runtime/start.js} +128 -39
- package/src/server/{auth.js → security/auth.js} +7 -8
- package/src/server/security/container-storage.js +382 -0
- package/src/server/{crypto.js → security/crypto.js} +1 -1
- package/src/server/security/selinux.js +185 -0
- package/src/server/{backup.js → storage/backup.js} +17 -8
- package/src/server/{data-query.js → storage/data-query.js} +1 -1
- package/src/server/{downloader.js → storage/downloader.js} +2 -2
- package/src/server/storage/repository.js +68 -0
- package/src/server.js +4 -7
- package/src/ws/IoInterface.js +1 -1
- package/src/ws/IoServer.js +1 -1
- package/src/ws/core/core.ws.connection.js +1 -1
- package/src/ws/core/core.ws.emit.js +1 -1
- package/src/ws/core/core.ws.server.js +1 -1
- package/src/ws/default/default.ws.connection.js +1 -1
- package/src/ws/default/default.ws.emit.js +1 -1
- package/src/ws/default/default.ws.server.js +1 -1
- package/test/e2e/event-e2e-public-ingress-down.js +45 -0
- package/test/e2e/event-e2e-wireguard-server-down.js +38 -0
- package/test/e2e/event-e2e-wireguard-spoke-down.js +40 -0
- package/test/{api.test.js → integration/app/api.test.js} +33 -14
- package/test/integration/app/cyberia/cyberia-cli-plain-reads.test.js +30 -0
- package/test/{cyberia-instance-conf-defaults.test.js → integration/app/cyberia/cyberia-instance-conf-defaults.test.js} +2 -1
- package/test/integration/app/cyberia/cyberia-load.test.js +467 -0
- package/test/integration/app/cyberia/fallback-world-capture.test.js +253 -0
- package/test/integration/app/cyberia/object-layer-item-id.test.js +327 -0
- package/test/{shape-generator.test.js → integration/app/cyberia/shape-generator.test.js} +1 -1
- package/test/integration/infra/1-security/config-scope.test.js +305 -0
- package/test/integration/infra/1-security/container-storage.test.js +356 -0
- package/test/integration/infra/1-security/in-pod-cli-surface.test.js +86 -0
- package/test/integration/infra/1-security/secret-onboarding.test.js +930 -0
- package/test/integration/infra/1-security/selinux.test.js +69 -0
- package/test/{sops-secret-store.test.js → integration/infra/1-security/sops-secret-store.test.js} +415 -61
- package/test/integration/infra/1-security/systemd-service.test.js +70 -0
- package/test/integration/infra/1-security/underpost-config-secret.test.js +367 -0
- package/test/integration/infra/2-network/dns-firewall.test.js +566 -0
- package/test/integration/infra/2-network/node-capability.test.js +182 -0
- package/test/integration/infra/2-network/wireguard-cli.test.js +1163 -0
- package/test/integration/infra/2-network/wireguard-edge.test.js +1731 -0
- package/test/{cluster-instances.test.js → integration/infra/3-cluster/cluster-instances.test.js} +11 -15
- package/test/{deploy-node-placement.test.js → integration/infra/3-cluster/deploy-node-placement.test.js} +3 -3
- package/test/integration/infra/3-cluster/docker-compose-stack.test.js +313 -0
- package/test/integration/infra/4-ingress/deploy-routes.test.js +379 -0
- package/test/integration/infra/4-ingress/gateway-static-assets.test.js +453 -0
- package/test/{instance-traffic-plan.test.js → integration/infra/4-ingress/instance-traffic-plan.test.js} +10 -6
- package/test/{underpost-gateway.test.js → integration/infra/4-ingress/underpost-gateway.test.js} +47 -6
- package/test/{underpost-ingress.test.js → integration/infra/4-ingress/underpost-ingress.test.js} +56 -4
- package/test/integration/infra/5-observability/cron-jobs.test.js +652 -0
- package/test/{deploy-monitor.test.js → integration/infra/5-observability/deploy-monitor.test.js} +29 -31
- package/test/integration/infra/5-observability/event-notification.test.js +197 -0
- package/test/integration/infra/5-observability/event-remediation.test.js +502 -0
- package/test/integration/infra/5-observability/event-targets.test.js +1174 -0
- package/test/integration/infra/5-observability/monitoring-stack.test.js +902 -0
- package/test/support/shell-harness.js +73 -0
- package/test/unit/build-template.test.js +97 -0
- package/test/unit/build-workflow-offline.test.js +132 -0
- package/test/unit/catalog.test.js +71 -0
- package/test/unit/client-build-docs.test.js +334 -0
- package/test/unit/conf-loading.test.js +303 -0
- package/test/unit/conf-resolution.test.js +979 -0
- package/test/unit/coverage-artifact.test.js +130 -0
- package/test/{crypto.test.js → unit/crypto.test.js} +1 -1
- package/test/unit/deploy-env-resolution.test.js +38 -0
- package/test/unit/deploy-log-table.test.js +447 -0
- package/test/unit/execution-profiles.test.js +219 -0
- package/test/unit/fleet-sync-source.test.js +149 -0
- package/test/unit/logger-redaction.test.js +112 -0
- package/test/unit/package.test.js +403 -0
- package/test/unit/prepare-host.test.js +299 -0
- package/test/unit/process-environment.test.js +18 -0
- package/test/unit/propagation-message.test.js +78 -0
- package/test/unit/redeploy-plan.test.js +24 -0
- package/test/unit/release-bump.test.js +474 -0
- package/test/unit/ssh-output-redaction.test.js +28 -0
- package/test/unit/start-options.test.js +46 -0
- package/test/unit/test-tiers.test.js +193 -0
- package/vitest.config.js +58 -0
- package/.nycrc +0 -9
- package/manifests/cronjobs/dd-cron/dd-cron-dns.yaml +0 -48
- package/manifests/mongodb/pv-pvc.yaml +0 -59
- package/scripts/link-local-underpost-cli.sh +0 -6
- package/src/api/user/user.build.js +0 -16
- package/src/cli/env.js +0 -177
- package/src/client/components/core/Blockchain.js +0 -41
- package/src/client/components/core/Blog.js +0 -9
- package/src/client/components/core/KeyboardAvoidance.js +0 -145
- package/src/client/public/default/assets/background/dark.jpg +0 -0
- package/src/client/public/default/assets/background/white0-min.jpg +0 -0
- package/src/client/public/default/assets/background/white0.jpg +0 -0
- package/src/client/public/doc/favicon.ico +0 -0
- package/src/client/public/doc/sitemap +0 -148
- package/src/server/cron.js +0 -476
package/src/server/cron.js
DELETED
|
@@ -1,476 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* UnderpostCron server module
|
|
3
|
-
* @module src/server/cron.js
|
|
4
|
-
* @namespace UnderpostCron
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { loggerFactory } from './logger.js';
|
|
8
|
-
import { shellExec } from './process.js';
|
|
9
|
-
import fs from 'fs-extra';
|
|
10
|
-
import Underpost from '../index.js';
|
|
11
|
-
import { getUnderpostRootPath, loadCronDeployEnv } from './conf.js';
|
|
12
|
-
|
|
13
|
-
const logger = loggerFactory(import.meta);
|
|
14
|
-
|
|
15
|
-
const volumeHostPath = '/home/dd';
|
|
16
|
-
const enginePath = '/home/dd/engine';
|
|
17
|
-
const cronVolumeName = 'underpost-cron-container-volume';
|
|
18
|
-
const shareEnvVolumeName = 'underpost-share-env';
|
|
19
|
-
const underpostContainerEnvDir = '/usr/lib/node_modules/underpost';
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Generates a Kubernetes CronJob YAML manifest string.
|
|
23
|
-
*
|
|
24
|
-
* @param {Object} params - CronJob parameters
|
|
25
|
-
* @param {string} params.name - CronJob name (max 52 chars, sanitized to DNS subdomain)
|
|
26
|
-
* @param {string} params.expression - Cron schedule expression (e.g., '0 0 * * *')
|
|
27
|
-
* @param {string} params.deployList - Comma-separated deploy IDs for the cron CLI
|
|
28
|
-
* @param {string} params.jobList - Comma-separated job IDs (e.g., 'dns', 'backup')
|
|
29
|
-
* @param {string} [params.image] - Container image (defaults to underpost/underpost-engine:<version>)
|
|
30
|
-
* @param {string} [params.namespace='default'] - Kubernetes namespace
|
|
31
|
-
* @param {boolean} [params.git=false] - Pass --git flag to cron CLI
|
|
32
|
-
* @param {boolean} [params.dev=false] - Use local ./ base path instead of global underpost installation
|
|
33
|
-
* @param {string} [params.cmd] - Optional pre-script commands to run before cron execution
|
|
34
|
-
* @param {boolean} [params.suspend=false] - Whether the CronJob is suspended
|
|
35
|
-
* @param {boolean} [params.dryRun=false] - Pass --dry-run flag to the cron command inside the container
|
|
36
|
-
* @param {boolean} [params.k3s=false] - Pass --k3s flag to the cron command inside the container
|
|
37
|
-
* @param {boolean} [params.kind=false] - Pass --kind flag to the cron command inside the container
|
|
38
|
-
* @param {boolean} [params.kubeadm=false] - Pass --kubeadm flag to the cron command inside the container
|
|
39
|
-
* @returns {string} Kubernetes CronJob YAML manifest
|
|
40
|
-
* @memberof UnderpostCron
|
|
41
|
-
*/
|
|
42
|
-
const cronJobYamlFactory = ({
|
|
43
|
-
name,
|
|
44
|
-
expression,
|
|
45
|
-
deployList,
|
|
46
|
-
jobList,
|
|
47
|
-
image,
|
|
48
|
-
namespace = 'default',
|
|
49
|
-
git = false,
|
|
50
|
-
dev = false,
|
|
51
|
-
cmd,
|
|
52
|
-
suspend = false,
|
|
53
|
-
dryRun = false,
|
|
54
|
-
k3s = false,
|
|
55
|
-
kind = false,
|
|
56
|
-
kubeadm = false,
|
|
57
|
-
}) => {
|
|
58
|
-
const containerImage = image || `underpost/underpost-engine:${Underpost.version}`;
|
|
59
|
-
|
|
60
|
-
const sanitizedName = name
|
|
61
|
-
.toLowerCase()
|
|
62
|
-
.replace(/[^a-z0-9-]/g, '-')
|
|
63
|
-
.replace(/--+/g, '-')
|
|
64
|
-
.replace(/^-|-$/g, '')
|
|
65
|
-
.substring(0, 52);
|
|
66
|
-
|
|
67
|
-
const cronBin = 'node bin'; // dev ? 'node bin' : 'underpost';
|
|
68
|
-
const flags = `${git ? '--git ' : ''}${dev ? '--dev ' : ''}${dryRun ? '--dry-run ' : ''}${k3s ? '--k3s ' : ''}${kind ? '--kind ' : ''}${kubeadm ? '--kubeadm ' : ''}`;
|
|
69
|
-
const commands = [`cd ${enginePath}`]; // `node bin run secret`
|
|
70
|
-
if (cmd) commands.push(cmd);
|
|
71
|
-
commands.push(`${cronBin} cron ${deployList} ${jobList} ${flags}`);
|
|
72
|
-
const fullCommand = commands.join(' &&\n ');
|
|
73
|
-
|
|
74
|
-
return `apiVersion: batch/v1
|
|
75
|
-
kind: CronJob
|
|
76
|
-
metadata:
|
|
77
|
-
name: ${sanitizedName}
|
|
78
|
-
namespace: ${namespace}
|
|
79
|
-
labels:
|
|
80
|
-
app: ${sanitizedName}
|
|
81
|
-
managed-by: underpost
|
|
82
|
-
spec:
|
|
83
|
-
schedule: "${expression}"
|
|
84
|
-
concurrencyPolicy: Forbid
|
|
85
|
-
startingDeadlineSeconds: 200
|
|
86
|
-
successfulJobsHistoryLimit: 3
|
|
87
|
-
failedJobsHistoryLimit: 1
|
|
88
|
-
suspend: ${suspend}
|
|
89
|
-
jobTemplate:
|
|
90
|
-
spec:
|
|
91
|
-
template:
|
|
92
|
-
metadata:
|
|
93
|
-
labels:
|
|
94
|
-
app: ${sanitizedName}
|
|
95
|
-
managed-by: underpost
|
|
96
|
-
spec:
|
|
97
|
-
containers:
|
|
98
|
-
- name: ${sanitizedName}
|
|
99
|
-
image: ${containerImage}
|
|
100
|
-
command:
|
|
101
|
-
- /bin/sh
|
|
102
|
-
- -c
|
|
103
|
-
- >
|
|
104
|
-
${fullCommand}
|
|
105
|
-
volumeMounts:
|
|
106
|
-
- mountPath: ${enginePath}
|
|
107
|
-
name: ${cronVolumeName}
|
|
108
|
-
- mountPath: ${underpostContainerEnvDir}
|
|
109
|
-
name: ${shareEnvVolumeName}
|
|
110
|
-
volumes:
|
|
111
|
-
- hostPath:
|
|
112
|
-
path: ${enginePath}
|
|
113
|
-
type: Directory
|
|
114
|
-
name: ${cronVolumeName}
|
|
115
|
-
- hostPath:
|
|
116
|
-
path: ${getUnderpostRootPath()}
|
|
117
|
-
type: DirectoryOrCreate
|
|
118
|
-
name: ${shareEnvVolumeName}
|
|
119
|
-
restartPolicy: OnFailure
|
|
120
|
-
`;
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Syncs the engine directory into the kind-worker container node.
|
|
125
|
-
* Required for kind clusters where worker nodes don't share the host filesystem.
|
|
126
|
-
*
|
|
127
|
-
* @memberof UnderpostCron
|
|
128
|
-
*/
|
|
129
|
-
const syncEngineToKindWorker = () => {
|
|
130
|
-
logger.info('Syncing engine volume to kind-worker node');
|
|
131
|
-
shellExec(`docker exec -i kind-worker bash -c "rm -rf ${volumeHostPath}"`);
|
|
132
|
-
shellExec(`docker exec -i kind-worker bash -c "mkdir -p ${volumeHostPath}"`);
|
|
133
|
-
shellExec(`docker cp ${volumeHostPath}/engine kind-worker:${volumeHostPath}/engine`);
|
|
134
|
-
shellExec(
|
|
135
|
-
`docker exec -i kind-worker bash -c "chown -R 1000:1000 ${volumeHostPath}; chmod -R 755 ${volumeHostPath}"`,
|
|
136
|
-
);
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Resolves the deploy-id to use for cron job generation.
|
|
141
|
-
* When deployId is provided directly, uses it. Otherwise reads from dd.cron file.
|
|
142
|
-
*
|
|
143
|
-
* @param {string} [deployId] - Explicit deploy-id override
|
|
144
|
-
* @memberof UnderpostCron
|
|
145
|
-
* @returns {string|null} Resolved deploy-id or null if not found
|
|
146
|
-
*/
|
|
147
|
-
const resolveDeployId = (deployId) => {
|
|
148
|
-
if (deployId) return deployId;
|
|
149
|
-
|
|
150
|
-
const cronDeployFilePath = './engine-private/deploy/dd.cron';
|
|
151
|
-
if (!fs.existsSync(cronDeployFilePath)) {
|
|
152
|
-
return null;
|
|
153
|
-
}
|
|
154
|
-
return fs.readFileSync(cronDeployFilePath, 'utf8').trim();
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* UnderpostCron main module methods
|
|
159
|
-
* @class UnderpostCron
|
|
160
|
-
* @memberof UnderpostCron
|
|
161
|
-
*/
|
|
162
|
-
class UnderpostCron {
|
|
163
|
-
/** @returns {Object} Available cron job handlers */
|
|
164
|
-
static get JOB() {
|
|
165
|
-
return {
|
|
166
|
-
dns: Underpost.dns,
|
|
167
|
-
backup: Underpost.backup,
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
static API = {
|
|
172
|
-
/**
|
|
173
|
-
* CLI entry point for the `underpost cron` command.
|
|
174
|
-
*
|
|
175
|
-
* @param {string} deployList - Comma-separated deploy IDs
|
|
176
|
-
* @param {string} jobList - Comma-separated job IDs
|
|
177
|
-
* @param {Object} options - CLI flags
|
|
178
|
-
* @param {boolean} [options.generateK8sCronjobs] - Generate K8s CronJob YAML manifests
|
|
179
|
-
* @param {boolean} [options.apply] - Apply manifests to the cluster
|
|
180
|
-
* @param {boolean} [options.git] - Pass --git to job execution
|
|
181
|
-
* @param {boolean} [options.dev] - Use local ./ base path instead of global underpost installation
|
|
182
|
-
* @param {string} [options.cmd] - Optional pre-script commands to run before cron execution
|
|
183
|
-
* @param {string} [options.namespace] - Kubernetes namespace
|
|
184
|
-
* @param {string} [options.image] - Custom container image
|
|
185
|
-
* @param {string} [options.setupStart] - Deploy-id to setup: updates its package.json start and generates+applies cron jobs
|
|
186
|
-
* @param {boolean} [options.k3s] - Use k3s cluster context (apply directly on host)
|
|
187
|
-
* @param {boolean} [options.kind] - Use kind cluster context (apply via kind-worker container)
|
|
188
|
-
* @param {boolean} [options.kubeadm] - Use kubeadm cluster context (apply directly on host)
|
|
189
|
-
* @param {boolean} [options.dryRun] - Preview cron jobs without executing them
|
|
190
|
-
* @param {boolean} [options.createJobNow] - After applying, immediately create a Job from each CronJob (requires --apply)
|
|
191
|
-
* @memberof UnderpostCron
|
|
192
|
-
*/
|
|
193
|
-
callback: async function (
|
|
194
|
-
deployList = 'default',
|
|
195
|
-
jobList = Object.keys(Underpost.cron.JOB).join(','),
|
|
196
|
-
options = {},
|
|
197
|
-
) {
|
|
198
|
-
loadCronDeployEnv();
|
|
199
|
-
if (options.setupStart) return await Underpost.cron.setupDeployStart(options.setupStart, options);
|
|
200
|
-
|
|
201
|
-
if (options.generateK8sCronjobs) return await Underpost.cron.generateK8sCronJobs(options);
|
|
202
|
-
|
|
203
|
-
for (const _jobId of jobList.split(',')) {
|
|
204
|
-
const jobId = _jobId.trim();
|
|
205
|
-
if (Underpost.cron.JOB[jobId]) {
|
|
206
|
-
if (options.dryRun) {
|
|
207
|
-
logger.info(`[dry-run] Would execute cron job`, { jobId, deployList, options });
|
|
208
|
-
} else {
|
|
209
|
-
logger.info(`Executing cron job`, { jobId, deployList, options });
|
|
210
|
-
await Underpost.cron.JOB[jobId].callback(deployList, options);
|
|
211
|
-
}
|
|
212
|
-
} else {
|
|
213
|
-
logger.warn(`Unknown cron job: ${jobId}`);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
},
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* Update the package.json start script for the given deploy-id and generate+apply its K8s CronJob manifests.
|
|
220
|
-
*
|
|
221
|
-
* @param {string} deployId - The deploy-id whose package.json will be updated
|
|
222
|
-
* @param {Object} [options] - Additional options forwarded to generateK8sCronJobs
|
|
223
|
-
* @param {boolean} [options.createJobNow] - After applying, immediately create a Job from each CronJob
|
|
224
|
-
* @param {boolean} [options.dryRun] - Pass --dry-run=client to kubectl commands
|
|
225
|
-
* @param {boolean} [options.apply] - Whether to apply generated manifests to the cluster
|
|
226
|
-
* @param {boolean} [options.git] - Pass --git flag to cron CLI commands
|
|
227
|
-
* @param {boolean} [options.dev] - Use local ./ base path instead of global underpost installation
|
|
228
|
-
* @param {string} [options.cmd] - Optional pre-script commands to run before cron execution
|
|
229
|
-
* @param {string} [options.namespace] - Kubernetes namespace for the CronJobs
|
|
230
|
-
* @param {string} [options.image] - Custom container image override for the CronJobs
|
|
231
|
-
* @param {boolean} [options.k3s] - k3s cluster context (apply directly on host)
|
|
232
|
-
* @param {boolean} [options.kind] - kind cluster context (apply via kind-worker container)
|
|
233
|
-
* @param {boolean} [options.kubeadm] - kubeadm cluster context (apply directly on host)
|
|
234
|
-
* @memberof UnderpostCron
|
|
235
|
-
*/
|
|
236
|
-
setupDeployStart: async function (deployId, options = {}) {
|
|
237
|
-
if (!deployId || deployId === true) deployId = resolveDeployId();
|
|
238
|
-
const confDir = `./engine-private/conf/${deployId}`;
|
|
239
|
-
const packageJsonPath = `${confDir}/package.json`;
|
|
240
|
-
const confCronPath = `${confDir}/conf.cron.json`;
|
|
241
|
-
|
|
242
|
-
if (!fs.existsSync(confCronPath)) {
|
|
243
|
-
logger.warn(`conf.cron.json not found for deploy-id: ${deployId}`, { path: confCronPath });
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
const confCron = JSON.parse(fs.readFileSync(confCronPath, 'utf8'));
|
|
248
|
-
|
|
249
|
-
if (!confCron.jobs || Object.keys(confCron.jobs).length === 0) {
|
|
250
|
-
logger.warn(`No cron jobs configured for deploy-id: ${deployId}`);
|
|
251
|
-
return;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
const hasEnabledJobs = Object.values(confCron.jobs).some((job) => job.enabled !== false);
|
|
255
|
-
if (!hasEnabledJobs) {
|
|
256
|
-
logger.warn(`No enabled cron jobs for deploy-id: ${deployId}`);
|
|
257
|
-
return;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
// Update package.json start script
|
|
261
|
-
if (fs.existsSync(packageJsonPath)) {
|
|
262
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
263
|
-
let startCommand = 'echo "Starting cron jobs..."';
|
|
264
|
-
for (const job of Object.keys(confCron.jobs))
|
|
265
|
-
startCommand += ` && kubectl apply -f ./manifests/cronjobs/${deployId}/${deployId}-${job}.yaml`;
|
|
266
|
-
if (!packageJson.scripts) packageJson.scripts = {};
|
|
267
|
-
packageJson.scripts.start = startCommand;
|
|
268
|
-
|
|
269
|
-
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 4) + '\n', 'utf8');
|
|
270
|
-
logger.info(`Updated package.json start script for ${deployId}`, { path: packageJsonPath });
|
|
271
|
-
} else {
|
|
272
|
-
logger.warn(`package.json not found for deploy-id: ${deployId}`, { path: packageJsonPath });
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
await Underpost.cron.generateK8sCronJobs({
|
|
276
|
-
deployId,
|
|
277
|
-
namespace: options.namespace,
|
|
278
|
-
image: options.image,
|
|
279
|
-
apply: options.apply,
|
|
280
|
-
createJobNow: options.createJobNow,
|
|
281
|
-
git: !!options.git,
|
|
282
|
-
dev: !!options.dev,
|
|
283
|
-
kubeadm: !!options.kubeadm,
|
|
284
|
-
cmd: options.cmd || `node bin env ${deployId} production`,
|
|
285
|
-
k3s: !!options.k3s,
|
|
286
|
-
kind: !!options.kind,
|
|
287
|
-
dryRun: !!options.dryRun,
|
|
288
|
-
});
|
|
289
|
-
},
|
|
290
|
-
|
|
291
|
-
/**
|
|
292
|
-
* Generate Kubernetes CronJob YAML manifests from conf.cron.json configuration.
|
|
293
|
-
* Each enabled job produces one CronJob YAML file under manifests/cronjobs/<deployId>/.
|
|
294
|
-
* With --apply the manifests are also applied to the cluster via kubectl.
|
|
295
|
-
*
|
|
296
|
-
* @param {Object} options
|
|
297
|
-
* @param {string} [options.deployId] - Explicit deploy-id (overrides dd.cron file lookup)
|
|
298
|
-
* @param {boolean} [options.git=false] - Pass --git flag to cron CLI commands
|
|
299
|
-
* @param {boolean} [options.dev=false] - Use local ./ base path instead of global underpost
|
|
300
|
-
* @param {string} [options.cmd] - Optional pre-script commands
|
|
301
|
-
* @param {boolean} [options.apply=false] - kubectl apply generated manifests
|
|
302
|
-
* @param {string} [options.namespace='default'] - Target Kubernetes namespace
|
|
303
|
-
* @param {string} [options.image] - Custom container image override
|
|
304
|
-
* @param {boolean} [options.k3s=false] - k3s cluster context (apply directly on host)
|
|
305
|
-
* @param {boolean} [options.kind=false] - kind cluster context (apply via kind-worker container)
|
|
306
|
-
* @param {boolean} [options.kubeadm=false] - kubeadm cluster context (apply directly on host)
|
|
307
|
-
* @param {boolean} [options.createJobNow=false] - After applying, create a Job from each CronJob immediately
|
|
308
|
-
* @param {boolean} [options.dryRun=false] - Pass --dry-run=client to kubectl commands
|
|
309
|
-
* @memberof UnderpostCron
|
|
310
|
-
*/
|
|
311
|
-
generateK8sCronJobs: async function (options = {}) {
|
|
312
|
-
const namespace = options.namespace || 'default';
|
|
313
|
-
const jobDeployId = resolveDeployId(options.deployId);
|
|
314
|
-
|
|
315
|
-
if (!jobDeployId) {
|
|
316
|
-
logger.warn(
|
|
317
|
-
'Could not resolve deploy-id. Provide --setup-start <deploy-id> or create engine-private/deploy/dd.cron',
|
|
318
|
-
);
|
|
319
|
-
return;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
const confCronPath = `./engine-private/conf/${jobDeployId}/conf.cron.json`;
|
|
323
|
-
|
|
324
|
-
if (!fs.existsSync(confCronPath)) {
|
|
325
|
-
logger.warn(`Cron configuration not found: ${confCronPath}`);
|
|
326
|
-
return;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
const confCronConfig = JSON.parse(fs.readFileSync(confCronPath, 'utf8'));
|
|
330
|
-
|
|
331
|
-
if (!confCronConfig.jobs || Object.keys(confCronConfig.jobs).length === 0) {
|
|
332
|
-
logger.info('No cron jobs configured');
|
|
333
|
-
return;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
const outputDir = `./manifests/cronjobs/${jobDeployId}`;
|
|
337
|
-
fs.mkdirSync(outputDir, { recursive: true });
|
|
338
|
-
|
|
339
|
-
const generatedFiles = [];
|
|
340
|
-
|
|
341
|
-
for (const job of Object.keys(confCronConfig.jobs)) {
|
|
342
|
-
const jobConfig = confCronConfig.jobs[job];
|
|
343
|
-
|
|
344
|
-
if (jobConfig.enabled === false) {
|
|
345
|
-
logger.info(`Skipping disabled job: ${job}`);
|
|
346
|
-
continue;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
const deployIdList = Underpost.cron.getRelatedDeployIdList(job);
|
|
350
|
-
const expression = jobConfig.expression || '0 0 * * *';
|
|
351
|
-
const cronJobName = `${jobDeployId}-${job}`;
|
|
352
|
-
|
|
353
|
-
const yamlContent = cronJobYamlFactory({
|
|
354
|
-
name: cronJobName,
|
|
355
|
-
expression,
|
|
356
|
-
deployList: deployIdList,
|
|
357
|
-
jobList: job,
|
|
358
|
-
image: options.image,
|
|
359
|
-
namespace,
|
|
360
|
-
git: !!options.git,
|
|
361
|
-
dev: !!options.dev,
|
|
362
|
-
cmd: options.cmd,
|
|
363
|
-
suspend: false,
|
|
364
|
-
dryRun: !!options.dryRun,
|
|
365
|
-
k3s: !!options.k3s,
|
|
366
|
-
kind: !!options.kind,
|
|
367
|
-
kubeadm: !!options.kubeadm,
|
|
368
|
-
});
|
|
369
|
-
|
|
370
|
-
const yamlFilePath = `${outputDir}/${cronJobName}.yaml`;
|
|
371
|
-
fs.writeFileSync(yamlFilePath, yamlContent, 'utf8');
|
|
372
|
-
generatedFiles.push(yamlFilePath);
|
|
373
|
-
|
|
374
|
-
logger.info(`Generated CronJob manifest: ${yamlFilePath}`, { job, expression, namespace });
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
if (options.apply) {
|
|
378
|
-
// Delete existing CronJobs before applying new ones
|
|
379
|
-
for (const job of Object.keys(confCronConfig.jobs)) {
|
|
380
|
-
const cronJobName = `${jobDeployId}-${job}`;
|
|
381
|
-
shellExec(`kubectl delete cronjob ${cronJobName} --namespace=${namespace} --ignore-not-found`);
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
// Ensure default dockerhub image is loaded on the cluster when no custom image is provided
|
|
385
|
-
if (!options.image) {
|
|
386
|
-
logger.info('Ensuring default image is loaded on cluster');
|
|
387
|
-
Underpost.image.pullDockerHubImage({
|
|
388
|
-
dockerhubImage: 'underpost',
|
|
389
|
-
kind: !!options.kind,
|
|
390
|
-
k3s: !!options.k3s,
|
|
391
|
-
kubeadm: !!options.kubeadm,
|
|
392
|
-
dev: !!options.dev,
|
|
393
|
-
});
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
// Sync engine volume to kind-worker node if using kind cluster
|
|
397
|
-
if (options.kind) {
|
|
398
|
-
syncEngineToKindWorker();
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
for (const yamlFile of generatedFiles) {
|
|
402
|
-
logger.info(`Applying: ${yamlFile}`);
|
|
403
|
-
shellExec(`kubectl apply -f ${yamlFile}`);
|
|
404
|
-
}
|
|
405
|
-
logger.info('All CronJob manifests applied');
|
|
406
|
-
} else {
|
|
407
|
-
logger.info(`Manifests generated in ${outputDir}. Use --apply to deploy to the cluster.`);
|
|
408
|
-
}
|
|
409
|
-
// Create an immediate Job from each CronJob if requested
|
|
410
|
-
if (options.createJobNow) {
|
|
411
|
-
for (const job of Object.keys(confCronConfig.jobs)) {
|
|
412
|
-
const jobConfig = confCronConfig.jobs[job];
|
|
413
|
-
if (jobConfig.enabled === false) continue;
|
|
414
|
-
|
|
415
|
-
const cronJobName = `${jobDeployId}-${job}`
|
|
416
|
-
.toLowerCase()
|
|
417
|
-
.replace(/[^a-z0-9-]/g, '-')
|
|
418
|
-
.replace(/--+/g, '-')
|
|
419
|
-
.replace(/^-|-$/g, '')
|
|
420
|
-
.substring(0, 52);
|
|
421
|
-
|
|
422
|
-
const immediateJobName = `${cronJobName}-now-${Date.now()}`.substring(0, 63);
|
|
423
|
-
logger.info(`Creating immediate Job from CronJob: ${cronJobName}`, { jobName: immediateJobName });
|
|
424
|
-
shellExec(`kubectl create job ${immediateJobName} --from=cronjob/${cronJobName} -n ${namespace}`);
|
|
425
|
-
}
|
|
426
|
-
logger.info('All immediate Jobs created');
|
|
427
|
-
}
|
|
428
|
-
},
|
|
429
|
-
|
|
430
|
-
/**
|
|
431
|
-
* Resolve the deploy-id list associated with a given job.
|
|
432
|
-
* Backup jobs read from dd.router (multiple deploy-ids); others from dd.cron.
|
|
433
|
-
*
|
|
434
|
-
* @param {string} jobId - Job identifier (e.g., 'dns', 'backup')
|
|
435
|
-
* @returns {string} Comma-separated deploy IDs
|
|
436
|
-
* @memberof UnderpostCron
|
|
437
|
-
*/
|
|
438
|
-
getRelatedDeployIdList(jobId) {
|
|
439
|
-
const deployFilePath =
|
|
440
|
-
jobId === 'backup' ? './engine-private/deploy/dd.router' : './engine-private/deploy/dd.cron';
|
|
441
|
-
|
|
442
|
-
if (!fs.existsSync(deployFilePath)) {
|
|
443
|
-
logger.warn(`Deploy file not found: ${deployFilePath}, using default`);
|
|
444
|
-
return fs.existsSync('./engine-private/deploy/dd.cron')
|
|
445
|
-
? fs.readFileSync('./engine-private/deploy/dd.cron', 'utf8').trim()
|
|
446
|
-
: 'dd-cron';
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
return fs.readFileSync(deployFilePath, 'utf8').trim();
|
|
450
|
-
},
|
|
451
|
-
|
|
452
|
-
/**
|
|
453
|
-
* Get the available cron job handlers.
|
|
454
|
-
* Each handler should have a callback function that executes the job logic.
|
|
455
|
-
* @memberof UnderpostCron
|
|
456
|
-
* @returns {Object} Available cron job handlers
|
|
457
|
-
*/
|
|
458
|
-
get JOB() {
|
|
459
|
-
return UnderpostCron.JOB;
|
|
460
|
-
},
|
|
461
|
-
|
|
462
|
-
/**
|
|
463
|
-
* Get the list of available job IDs.
|
|
464
|
-
* This is derived from the keys of the JOB object.
|
|
465
|
-
* @memberof UnderpostCron
|
|
466
|
-
* @returns {string[]} List of available job IDs
|
|
467
|
-
*/
|
|
468
|
-
getJobsIDs() {
|
|
469
|
-
return Object.keys(UnderpostCron.JOB);
|
|
470
|
-
},
|
|
471
|
-
};
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
export default UnderpostCron;
|
|
475
|
-
|
|
476
|
-
export { cronJobYamlFactory, resolveDeployId };
|