underpost 3.0.3 → 3.1.1
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.production → .env.example} +20 -2
- package/.github/workflows/ghpkg.ci.yml +1 -1
- package/.github/workflows/gitlab.ci.yml +1 -1
- package/.github/workflows/npmpkg.ci.yml +22 -7
- package/.github/workflows/publish.ci.yml +5 -5
- package/.github/workflows/pwa-microservices-template-page.cd.yml +3 -3
- package/.github/workflows/pwa-microservices-template-test.ci.yml +1 -1
- package/.github/workflows/release.cd.yml +3 -2
- package/.vscode/extensions.json +9 -8
- package/.vscode/settings.json +3 -2
- package/CHANGELOG.md +160 -1
- package/CLI-HELP.md +71 -52
- package/README.md +2 -2
- package/bin/build.js +4 -1
- package/bin/deploy.js +150 -208
- package/bin/file.js +2 -1
- package/bin/vs.js +3 -3
- package/conf.js +30 -13
- package/manifests/cronjobs/dd-cron/dd-cron-backup.yaml +1 -1
- package/manifests/cronjobs/dd-cron/dd-cron-dns.yaml +1 -1
- package/manifests/deployment/dd-default-development/deployment.yaml +2 -2
- package/manifests/deployment/dd-test-development/deployment.yaml +52 -52
- package/manifests/deployment/dd-test-development/proxy.yaml +4 -4
- package/manifests/pv-pvc-dd.yaml +1 -1
- package/package.json +48 -43
- package/scripts/k3s-node-setup.sh +1 -1
- package/src/api/document/document.service.js +1 -1
- package/src/api/file/file.controller.js +3 -1
- package/src/api/file/file.service.js +28 -5
- package/src/api/user/user.router.js +10 -5
- package/src/api/user/user.service.js +7 -7
- package/src/cli/baremetal.js +6 -10
- package/src/cli/cloud-init.js +0 -3
- package/src/cli/db.js +54 -71
- package/src/cli/deploy.js +64 -12
- package/src/cli/env.js +5 -5
- package/src/cli/fs.js +0 -2
- package/src/cli/image.js +0 -3
- package/src/cli/index.js +27 -13
- package/src/cli/monitor.js +5 -6
- package/src/cli/repository.js +329 -35
- package/src/cli/run.js +118 -69
- package/src/cli/secrets.js +1 -3
- package/src/cli/ssh.js +1 -1
- package/src/client/components/core/AgGrid.js +20 -5
- package/src/client/components/core/Content.js +22 -3
- package/src/client/components/core/Docs.js +21 -4
- package/src/client/components/core/FileExplorer.js +71 -4
- package/src/client/components/core/Input.js +1 -1
- package/src/client/components/core/Modal.js +20 -6
- package/src/client/public/default/sitemap +3 -3
- package/src/client/public/test/sitemap +3 -3
- package/src/client.build.js +0 -3
- package/src/client.dev.js +0 -3
- package/src/db/DataBaseProvider.js +17 -2
- package/src/db/mariadb/MariaDB.js +14 -9
- package/src/db/mongo/MongooseDB.js +17 -1
- package/src/index.js +1 -1
- package/src/proxy.js +0 -3
- package/src/runtime/express/Express.js +7 -1
- package/src/runtime/lampp/Lampp.js +6 -13
- package/src/server/auth.js +6 -9
- package/src/server/backup.js +2 -3
- package/src/server/client-build-docs.js +178 -3
- package/src/server/client-build-live.js +9 -18
- package/src/server/client-build.js +175 -38
- package/src/server/client-dev-server.js +14 -13
- package/src/server/conf.js +357 -149
- package/src/server/cron.js +2 -1
- package/src/server/dns.js +28 -12
- package/src/server/downloader.js +0 -2
- package/src/server/logger.js +27 -9
- package/src/server/peer.js +0 -2
- package/src/server/process.js +1 -50
- package/src/server/proxy.js +4 -8
- package/src/server/runtime.js +5 -8
- package/src/server/ssr.js +0 -3
- package/src/server/start.js +5 -5
- package/src/server/tls.js +0 -2
- package/src/server.js +0 -4
- package/.env.development +0 -43
- package/.env.test +0 -43
package/src/server/cron.js
CHANGED
|
@@ -8,7 +8,7 @@ import { loggerFactory } from './logger.js';
|
|
|
8
8
|
import { shellExec } from './process.js';
|
|
9
9
|
import fs from 'fs-extra';
|
|
10
10
|
import Underpost from '../index.js';
|
|
11
|
-
import { getUnderpostRootPath } from './conf.js';
|
|
11
|
+
import { getUnderpostRootPath, loadCronDeployEnv } from './conf.js';
|
|
12
12
|
|
|
13
13
|
const logger = loggerFactory(import.meta);
|
|
14
14
|
|
|
@@ -191,6 +191,7 @@ class UnderpostCron {
|
|
|
191
191
|
jobList = Object.keys(Underpost.cron.JOB).join(','),
|
|
192
192
|
options = {},
|
|
193
193
|
) {
|
|
194
|
+
loadCronDeployEnv();
|
|
194
195
|
if (options.setupStart) return await Underpost.cron.setupDeployStart(options.setupStart, options);
|
|
195
196
|
|
|
196
197
|
if (options.generateK8sCronjobs) return await Underpost.cron.generateK8sCronJobs(options);
|
package/src/server/dns.js
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
* @namespace UnderpostDns
|
|
6
6
|
*/
|
|
7
7
|
import axios from 'axios';
|
|
8
|
-
import dotenv from 'dotenv';
|
|
9
8
|
import fs from 'fs';
|
|
10
9
|
import validator from 'validator';
|
|
11
10
|
import { loggerFactory } from './logger.js';
|
|
@@ -13,11 +12,9 @@ import dns from 'node:dns';
|
|
|
13
12
|
import os from 'node:os';
|
|
14
13
|
import { shellExec, pbcopy } from './process.js';
|
|
15
14
|
import Underpost from '../index.js';
|
|
16
|
-
import { writeEnv } from './conf.js';
|
|
15
|
+
import { writeEnv, readConfJson, loadCronDeployEnv } from './conf.js';
|
|
17
16
|
import { resolveDeployId } from './cron.js';
|
|
18
17
|
|
|
19
|
-
dotenv.config();
|
|
20
|
-
|
|
21
18
|
const logger = loggerFactory(import.meta);
|
|
22
19
|
|
|
23
20
|
/**
|
|
@@ -268,6 +265,7 @@ class Dns {
|
|
|
268
265
|
* @returns {Promise<void>}
|
|
269
266
|
*/
|
|
270
267
|
static async callback(deployList) {
|
|
268
|
+
loadCronDeployEnv();
|
|
271
269
|
const isOnline = await Dns.isInternetConnection();
|
|
272
270
|
|
|
273
271
|
if (!isOnline) return;
|
|
@@ -288,16 +286,15 @@ class Dns {
|
|
|
288
286
|
|
|
289
287
|
for (const _deployId of deployList.split(',')) {
|
|
290
288
|
const deployId = _deployId.trim();
|
|
291
|
-
const privateCronConfPath = `./engine-private/conf/${deployId}/conf.cron.json`;
|
|
292
|
-
const confCronPath = fs.existsSync(privateCronConfPath) ? privateCronConfPath : './conf/conf.cron.json';
|
|
293
289
|
|
|
294
|
-
|
|
295
|
-
|
|
290
|
+
let confCronData;
|
|
291
|
+
try {
|
|
292
|
+
confCronData = readConfJson(deployId, 'cron', { resolve: true });
|
|
293
|
+
} catch (error) {
|
|
294
|
+
logger.warn(`Cron config file not found for deployId: ${deployId}`, { message: error.message });
|
|
296
295
|
continue;
|
|
297
296
|
}
|
|
298
297
|
|
|
299
|
-
const confCronData = JSON.parse(fs.readFileSync(confCronPath, 'utf8'));
|
|
300
|
-
|
|
301
298
|
if (!confCronData.records) {
|
|
302
299
|
logger.warn(`'records' field missing in cron config for deployId: ${deployId}`);
|
|
303
300
|
continue;
|
|
@@ -365,8 +362,26 @@ class Dns {
|
|
|
365
362
|
*/
|
|
366
363
|
dondominio: (options) => {
|
|
367
364
|
const { user, api_key, host, dns, ip } = options;
|
|
365
|
+
|
|
366
|
+
// Validate that required credentials are present before making any request
|
|
367
|
+
if (!user || !api_key) {
|
|
368
|
+
logger.error(
|
|
369
|
+
`${dns} update aborted: missing credentials. ` +
|
|
370
|
+
`Ensure DDNS_USER and DDNS_API_KEY environment variables are set ` +
|
|
371
|
+
`or provide 'user' and 'api_key' in cron records configuration.`,
|
|
372
|
+
{ host, hasUser: !!user, hasApiKey: !!api_key },
|
|
373
|
+
);
|
|
374
|
+
return Promise.resolve(false);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
if (!host) {
|
|
378
|
+
logger.error(`${dns} update aborted: missing host. Set DDNS_HOST or provide 'host' in cron records.`);
|
|
379
|
+
return Promise.resolve(false);
|
|
380
|
+
}
|
|
381
|
+
|
|
368
382
|
const url = `https://dondns.dondominio.com/json/?user=${user}&password=${api_key}&host=${host}&ip=${ip}`;
|
|
369
|
-
|
|
383
|
+
// Log the update attempt without exposing the full URL containing credentials
|
|
384
|
+
logger.info(`${dns} update ip request`, { host, ip });
|
|
370
385
|
|
|
371
386
|
// Prevent live IP update in non-production environments
|
|
372
387
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -382,7 +397,8 @@ class Dns {
|
|
|
382
397
|
return resolve(true);
|
|
383
398
|
})
|
|
384
399
|
.catch((error) => {
|
|
385
|
-
|
|
400
|
+
// Only log the error message — the full error object contains the request URL with credentials
|
|
401
|
+
logger.error(`${dns} update ip error`, { message: error.message, host, ip });
|
|
386
402
|
return resolve(false);
|
|
387
403
|
});
|
|
388
404
|
});
|
package/src/server/downloader.js
CHANGED
package/src/server/logger.js
CHANGED
|
@@ -6,16 +6,14 @@
|
|
|
6
6
|
|
|
7
7
|
'use strict';
|
|
8
8
|
|
|
9
|
-
import dotenv from 'dotenv';
|
|
10
9
|
import winston from 'winston';
|
|
11
10
|
import morgan from 'morgan';
|
|
12
|
-
import colorize from 'json-colorizer';
|
|
11
|
+
import { colorize, color } from 'json-colorizer';
|
|
13
12
|
import colors from 'colors';
|
|
14
13
|
import v8 from 'v8';
|
|
15
14
|
import { clearTerminalStringColor, formatBytes } from '../client/components/core/CommonJs.js';
|
|
16
15
|
|
|
17
16
|
colors.enable();
|
|
18
|
-
dotenv.config();
|
|
19
17
|
|
|
20
18
|
// Define your severity levels.
|
|
21
19
|
// With them, You can create log files,
|
|
@@ -60,14 +58,34 @@ const format = (meta) =>
|
|
|
60
58
|
winston.format.colorize({ all: true }),
|
|
61
59
|
// Define the format of the message showing the timestamp, the level and the message
|
|
62
60
|
winston.format.printf((info) => {
|
|
63
|
-
const
|
|
61
|
+
const splatKey = Symbol.for('splat');
|
|
62
|
+
const splat = info[splatKey];
|
|
63
|
+
const hasSplat = Array.isArray(splat) && splat.length > 0 && splat[0] !== undefined;
|
|
64
|
+
let splatStr = '';
|
|
65
|
+
if (hasSplat) {
|
|
66
|
+
const seen = new WeakSet();
|
|
67
|
+
splatStr = JSON.stringify(
|
|
68
|
+
splat[0],
|
|
69
|
+
(key, value) => {
|
|
70
|
+
if (typeof value === 'function') return `[Function: ${value.name || 'anonymous'}]`;
|
|
71
|
+
if (typeof value === 'object' && value !== null) {
|
|
72
|
+
if (seen.has(value)) return '[Circular]';
|
|
73
|
+
seen.add(value);
|
|
74
|
+
}
|
|
75
|
+
return value;
|
|
76
|
+
},
|
|
77
|
+
4,
|
|
78
|
+
);
|
|
79
|
+
}
|
|
64
80
|
return `${`[${meta}]`.green} ${info.timestamp} ${info.level} ${
|
|
65
|
-
|
|
66
|
-
? `${clearTerminalStringColor(info.message)}: ${colorize(
|
|
81
|
+
hasSplat
|
|
82
|
+
? `${clearTerminalStringColor(info.message)}: ${colorize(splatStr, {
|
|
67
83
|
colors: {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
84
|
+
StringKey: color.green,
|
|
85
|
+
StringLiteral: color.magenta,
|
|
86
|
+
NumberLiteral: color.red,
|
|
87
|
+
BooleanLiteral: color.cyan,
|
|
88
|
+
NullLiteral: color.white,
|
|
71
89
|
},
|
|
72
90
|
})}`
|
|
73
91
|
: info.message
|
package/src/server/peer.js
CHANGED
package/src/server/process.js
CHANGED
|
@@ -8,14 +8,11 @@
|
|
|
8
8
|
// https://nodejs.org/api/process
|
|
9
9
|
|
|
10
10
|
import shell from 'shelljs';
|
|
11
|
-
import dotenv from 'dotenv';
|
|
12
11
|
import { loggerFactory } from './logger.js';
|
|
13
12
|
import clipboard from 'clipboardy';
|
|
14
13
|
import Underpost from '../index.js';
|
|
15
14
|
import { getNpmRootPath } from './conf.js';
|
|
16
15
|
|
|
17
|
-
dotenv.config();
|
|
18
|
-
|
|
19
16
|
const logger = loggerFactory(import.meta);
|
|
20
17
|
|
|
21
18
|
/**
|
|
@@ -122,52 +119,6 @@ const shellCd = (cd, options = { disableLog: false }) => {
|
|
|
122
119
|
return shell.cd(cd);
|
|
123
120
|
};
|
|
124
121
|
|
|
125
|
-
/**
|
|
126
|
-
* Opens a new GNOME terminal and executes a command.
|
|
127
|
-
* Note: This function is environment-specific (GNOME/Linux).
|
|
128
|
-
* @memberof Process
|
|
129
|
-
* @param {string} cmd - The command to execute in the new terminal.
|
|
130
|
-
* @param {Object} [options] - Options for the terminal opening.
|
|
131
|
-
* @param {boolean} [options.single=false] - If true, execute as a single session process using `setsid`.
|
|
132
|
-
* @param {string} [options.chown] - Path to change ownership to the target user.
|
|
133
|
-
* @returns {void}
|
|
134
|
-
*/
|
|
135
|
-
const openTerminal = (cmd, options = { single: false }) => {
|
|
136
|
-
// Find the graphical user's UID from /run/user (prefer non-root UID, usually 1000)
|
|
137
|
-
const IDS = shellExec(`ls -1 /run/user`, { stdout: true, silent: true })
|
|
138
|
-
.split('\n')
|
|
139
|
-
.map((v) => v.trim())
|
|
140
|
-
.filter(Boolean);
|
|
141
|
-
|
|
142
|
-
const nonRootIds = IDS.filter((id) => id !== '0');
|
|
143
|
-
const ID = nonRootIds.length > 0 ? nonRootIds[0] : IDS[0];
|
|
144
|
-
|
|
145
|
-
if (!options.chown) options.chown = `/home/dd ${getNpmRootPath()}/underpost`;
|
|
146
|
-
|
|
147
|
-
shellExec(`chown -R ${ID}:${ID} ${options.chown}`);
|
|
148
|
-
|
|
149
|
-
// Run the terminal as the graphical user and use THAT user's runtime dir/bus.
|
|
150
|
-
const confCmd = `USER_GRAPHICAL=$(getent passwd "${ID}" | cut -d: -f1); \
|
|
151
|
-
sudo -u "$USER_GRAPHICAL" env DISPLAY="$DISPLAY" \
|
|
152
|
-
XDG_RUNTIME_DIR="/run/user/${ID}" \
|
|
153
|
-
DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/${ID}/bus" \
|
|
154
|
-
PATH="$PATH" \
|
|
155
|
-
`;
|
|
156
|
-
|
|
157
|
-
if (options.single === true) {
|
|
158
|
-
// Run as a single session process
|
|
159
|
-
shellExec(`${confCmd} setsid gnome-terminal -- bash -ic '${cmd}; exec bash' >/dev/null 2>&1 &`, {
|
|
160
|
-
async: true,
|
|
161
|
-
});
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
// Run asynchronously and disown
|
|
165
|
-
shellExec(`${confCmd} gnome-terminal -- bash -c '${cmd}; exec bash' >/dev/null 2>&1 & disown`, {
|
|
166
|
-
async: true,
|
|
167
|
-
stdout: true,
|
|
168
|
-
});
|
|
169
|
-
};
|
|
170
|
-
|
|
171
122
|
/**
|
|
172
123
|
* Wraps a command to run it as a daemon process in a shell (keeping the process alive/terminal open).
|
|
173
124
|
* @memberof Process
|
|
@@ -198,4 +149,4 @@ function pbcopy(data) {
|
|
|
198
149
|
logger.info(`copied to clipboard`, clipboard.readSync());
|
|
199
150
|
}
|
|
200
151
|
|
|
201
|
-
export { ProcessController, getRootDirectory, shellExec, shellCd, pbcopy,
|
|
152
|
+
export { ProcessController, getRootDirectory, shellExec, shellCd, pbcopy, getTerminalPid, daemonProcess };
|
package/src/server/proxy.js
CHANGED
|
@@ -7,8 +7,6 @@
|
|
|
7
7
|
'use strict';
|
|
8
8
|
|
|
9
9
|
import express from 'express';
|
|
10
|
-
import dotenv from 'dotenv';
|
|
11
|
-
|
|
12
10
|
import { createProxyMiddleware } from 'http-proxy-middleware';
|
|
13
11
|
import { loggerFactory, loggerMiddleware } from './logger.js';
|
|
14
12
|
import { buildPortProxyRouter, buildProxyRouter, getTlsHosts, isDevProxyContext, isTlsDevProxy } from './conf.js';
|
|
@@ -17,8 +15,6 @@ import { shellExec } from './process.js';
|
|
|
17
15
|
import fs from 'fs-extra';
|
|
18
16
|
import Underpost from '../index.js';
|
|
19
17
|
|
|
20
|
-
dotenv.config();
|
|
21
|
-
|
|
22
18
|
const logger = loggerFactory(import.meta);
|
|
23
19
|
|
|
24
20
|
/**
|
|
@@ -56,11 +52,12 @@ class ProxyService {
|
|
|
56
52
|
// Proxy middleware options
|
|
57
53
|
/** @type {import('http-proxy-middleware/dist/types').Options} */
|
|
58
54
|
const options = {
|
|
55
|
+
pathFilter: proxyPath, // Use '/' as the general filter (v3 API)
|
|
59
56
|
ws: true, // Enable websocket proxying
|
|
60
57
|
target: `http://localhost:${parseInt(process.env.PORT - 1)}`, // Default target (should be overridden by router)
|
|
61
58
|
router: {},
|
|
62
59
|
// changeOrigin: true,
|
|
63
|
-
|
|
60
|
+
logger: logger,
|
|
64
61
|
xfwd: true, // Adds x-forward headers (Host, Proto, etc.)
|
|
65
62
|
onProxyReq: (proxyReq, req, res, options) => {},
|
|
66
63
|
pathRewrite: {},
|
|
@@ -74,8 +71,7 @@ class ProxyService {
|
|
|
74
71
|
devProxyContext: process.env.NODE_ENV !== 'production',
|
|
75
72
|
});
|
|
76
73
|
|
|
77
|
-
|
|
78
|
-
app.use(proxyPath, createProxyMiddleware(filter, options));
|
|
74
|
+
app.use(proxyPath, createProxyMiddleware(options));
|
|
79
75
|
|
|
80
76
|
// Determine which server to start (HTTP or HTTPS) based on port and environment
|
|
81
77
|
switch (process.env.NODE_ENV) {
|
|
@@ -115,7 +111,7 @@ class ProxyService {
|
|
|
115
111
|
break;
|
|
116
112
|
}
|
|
117
113
|
}
|
|
118
|
-
logger.info('Proxy running', { port, options });
|
|
114
|
+
logger.info('Proxy running', { port, router: options.router });
|
|
119
115
|
if (process.env.NODE_ENV === 'development')
|
|
120
116
|
logger.info(
|
|
121
117
|
Underpost.deploy.etcHostFactory(Object.keys(options.router), {
|
package/src/server/runtime.js
CHANGED
|
@@ -6,21 +6,17 @@
|
|
|
6
6
|
* @namespace Runtime
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import fs from 'fs-extra';
|
|
10
|
-
import dotenv from 'dotenv';
|
|
11
9
|
import * as promClient from 'prom-client';
|
|
12
10
|
|
|
13
11
|
import { loggerFactory } from './logger.js';
|
|
14
12
|
import { newInstance } from '../client/components/core/CommonJs.js';
|
|
15
13
|
import { Lampp } from '../runtime/lampp/Lampp.js';
|
|
16
|
-
import { getInstanceContext } from './conf.js';
|
|
14
|
+
import { getInstanceContext, readConfJson } from './conf.js';
|
|
17
15
|
|
|
18
16
|
import ExpressService from '../runtime/express/Express.js';
|
|
19
17
|
|
|
20
18
|
import Underpost from '../index.js';
|
|
21
19
|
|
|
22
|
-
dotenv.config();
|
|
23
|
-
|
|
24
20
|
const logger = loggerFactory(import.meta);
|
|
25
21
|
|
|
26
22
|
/**
|
|
@@ -48,9 +44,9 @@ const buildRuntime = async () => {
|
|
|
48
44
|
const initPort = parseInt(process.env.PORT) + 1;
|
|
49
45
|
let currentPort = initPort;
|
|
50
46
|
|
|
51
|
-
// Load Configuration
|
|
52
|
-
const confServer =
|
|
53
|
-
const confSSR =
|
|
47
|
+
// Load Configuration — resolve env: secret references at actual server runtime
|
|
48
|
+
const confServer = readConfJson(deployId, 'server', { resolve: true, loadReplicas: true });
|
|
49
|
+
const confSSR = readConfJson(deployId, 'ssr');
|
|
54
50
|
|
|
55
51
|
// Iterate through hosts and paths
|
|
56
52
|
for (const host of Object.keys(confServer)) {
|
|
@@ -83,6 +79,7 @@ const buildRuntime = async () => {
|
|
|
83
79
|
redirect,
|
|
84
80
|
singleReplica,
|
|
85
81
|
replicas,
|
|
82
|
+
peer,
|
|
86
83
|
});
|
|
87
84
|
|
|
88
85
|
if (singleReplicaOffsetPortSum > 0) {
|
package/src/server/ssr.js
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import fs from 'fs-extra';
|
|
8
|
-
import dotenv from 'dotenv';
|
|
9
8
|
import vm from 'node:vm';
|
|
10
9
|
|
|
11
10
|
import Underpost from '../index.js';
|
|
@@ -14,8 +13,6 @@ import { srcFormatted, JSONweb } from './client-formatted.js';
|
|
|
14
13
|
import { loggerFactory } from './logger.js';
|
|
15
14
|
import { getRootDirectory } from './process.js';
|
|
16
15
|
|
|
17
|
-
dotenv.config();
|
|
18
|
-
|
|
19
16
|
const logger = loggerFactory(import.meta);
|
|
20
17
|
|
|
21
18
|
/**
|
package/src/server/start.js
CHANGED
|
@@ -161,13 +161,13 @@ class UnderpostStartUp {
|
|
|
161
161
|
shellExec(`cd ${buildBasePath}/engine && sudo mv ./${repoName}-private ./engine-private`);
|
|
162
162
|
shellCd(`${buildBasePath}/engine`);
|
|
163
163
|
shellExec(options?.underpostQuicklyInstall ? `underpost install` : `npm install`);
|
|
164
|
-
shellExec(`node bin
|
|
164
|
+
shellExec(`node bin env ${deployId} ${env}`);
|
|
165
165
|
if (fs.existsSync('./engine-private/itc-scripts')) {
|
|
166
166
|
const itcScripts = await fs.readdir('./engine-private/itc-scripts');
|
|
167
167
|
for (const itcScript of itcScripts)
|
|
168
168
|
if (itcScript.match(deployId)) shellExec(`node ./engine-private/itc-scripts/${itcScript}`);
|
|
169
169
|
}
|
|
170
|
-
|
|
170
|
+
await Underpost.repo.client(deployId);
|
|
171
171
|
},
|
|
172
172
|
/**
|
|
173
173
|
* Runs a deployment.
|
|
@@ -177,17 +177,17 @@ class UnderpostStartUp {
|
|
|
177
177
|
* @memberof UnderpostStartUp
|
|
178
178
|
*/
|
|
179
179
|
async run(deployId = 'dd-default', env = 'development', options = {}) {
|
|
180
|
-
const runCmd = env === 'production' ? 'run prod
|
|
180
|
+
const runCmd = env === 'production' ? 'run prod:container' : 'run dev:container';
|
|
181
181
|
if (fs.existsSync(`./engine-private/replica`)) {
|
|
182
182
|
const replicas = await fs.readdir(`./engine-private/replica`);
|
|
183
183
|
for (const replica of replicas) {
|
|
184
184
|
if (!replica.match(deployId)) continue;
|
|
185
|
-
shellExec(`node bin
|
|
185
|
+
shellExec(`node bin env ${replica} ${env}`);
|
|
186
186
|
shellExec(`npm ${runCmd} ${replica}`, { async: true });
|
|
187
187
|
await awaitDeployMonitor(true);
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
|
-
shellExec(`node bin
|
|
190
|
+
shellExec(`node bin env ${deployId} ${env}`);
|
|
191
191
|
shellExec(`npm ${runCmd} ${deployId}`, { async: true });
|
|
192
192
|
await awaitDeployMonitor(true);
|
|
193
193
|
Underpost.env.set('container-status', `${deployId}-${env}-running-deployment`);
|
package/src/server/tls.js
CHANGED
|
@@ -7,10 +7,8 @@
|
|
|
7
7
|
import fs from 'fs-extra';
|
|
8
8
|
import https from 'https';
|
|
9
9
|
import path from 'path';
|
|
10
|
-
import dotenv from 'dotenv';
|
|
11
10
|
import { loggerFactory } from './logger.js';
|
|
12
11
|
|
|
13
|
-
dotenv.config();
|
|
14
12
|
const logger = loggerFactory(import.meta);
|
|
15
13
|
|
|
16
14
|
const DEFAULT_HOST = 'localhost';
|
package/src/server.js
CHANGED
|
@@ -3,15 +3,11 @@
|
|
|
3
3
|
// https://nodejs.org/api
|
|
4
4
|
// https://expressjs.com/en/4x/api.html
|
|
5
5
|
|
|
6
|
-
import dotenv from 'dotenv';
|
|
7
6
|
import { loggerFactory } from './server/logger.js';
|
|
8
7
|
import { buildClient } from './server/client-build.js';
|
|
9
8
|
import { buildRuntime } from './server/runtime.js';
|
|
10
9
|
import { ProcessController } from './server/process.js';
|
|
11
10
|
import { Config } from './server/conf.js';
|
|
12
|
-
|
|
13
|
-
dotenv.config();
|
|
14
|
-
|
|
15
11
|
await Config.build();
|
|
16
12
|
|
|
17
13
|
const logger = loggerFactory(import.meta);
|
package/.env.development
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
DEPLOY_ID=dd-default
|
|
2
|
-
NODE_ENV=development
|
|
3
|
-
PORT=4000
|
|
4
|
-
JWT_SECRET=test
|
|
5
|
-
REFRESH_EXPIRE_MINUTES=5
|
|
6
|
-
ACCESS_EXPIRE_MINUTES=1440
|
|
7
|
-
NODE_OPTIONS=--max-old-space-size=8192
|
|
8
|
-
TIME_ZONE=changethis
|
|
9
|
-
GITHUB_TOKEN=changethis
|
|
10
|
-
GITHUB_USERNAME=changethis
|
|
11
|
-
GITHUB_BACKUP_REPO=changethis
|
|
12
|
-
GITHUB_DNS_REPO=changethis
|
|
13
|
-
DEFAULT_DEPLOY_ID=dd-default
|
|
14
|
-
DEFAULT_DEPLOY_HOST=default.net
|
|
15
|
-
DEFAULT_DEPLOY_PATH=/
|
|
16
|
-
MARIADB_HOST=changethis
|
|
17
|
-
MARIADB_USER=changethis
|
|
18
|
-
MARIADB_PASSWORD=changethis
|
|
19
|
-
CLOUDINARY_CLOUD_NAME=changethis
|
|
20
|
-
CLOUDINARY_API_KEY=changethis
|
|
21
|
-
CLOUDINARY_API_SECRET=changethis
|
|
22
|
-
CLOUDINARY_PASSWORD=changethis
|
|
23
|
-
CLOUDINARY_EMAIL=admin@default.net
|
|
24
|
-
DB_PG_MAAS_NAME=changethis
|
|
25
|
-
DB_PG_MAAS_PASS=changethis
|
|
26
|
-
DB_PG_MAAS_USER=changethis
|
|
27
|
-
DB_PG_MAAS_HOST=127.0.0.1
|
|
28
|
-
DB_PG_MAAS_PORT=5432
|
|
29
|
-
MAAS_ADMIN_USERNAME=changethis
|
|
30
|
-
MAAS_API_KEY=changethis
|
|
31
|
-
MAAS_ADMIN_EMAIL=admin@default.net
|
|
32
|
-
MAAS_ADMIN_PASS=changethis
|
|
33
|
-
TFTP_ROOT=changethis
|
|
34
|
-
NETMASK=255.255.255.0
|
|
35
|
-
MAAS_DNS=8.8.8.8
|
|
36
|
-
MAAS_NTP_SERVER=changethis
|
|
37
|
-
NFS_EXPORT_PATH=changethis
|
|
38
|
-
NVIDIA_API_KEY=changethis
|
|
39
|
-
DEFAULT_ADMIN_EMAIL=admin@default.net
|
|
40
|
-
DEFAULT_ADMIN_PASSWORD=changethis
|
|
41
|
-
DEFAULT_SSH_PORT=22
|
|
42
|
-
BASE_API=api
|
|
43
|
-
DEV_PROXY_PORT_OFFSET=200
|
package/.env.test
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
DEPLOY_ID=dd-default
|
|
2
|
-
NODE_ENV=test
|
|
3
|
-
PORT=5000
|
|
4
|
-
JWT_SECRET=test
|
|
5
|
-
REFRESH_EXPIRE_MINUTES=5
|
|
6
|
-
ACCESS_EXPIRE_MINUTES=1440
|
|
7
|
-
NODE_OPTIONS=--max-old-space-size=8192
|
|
8
|
-
TIME_ZONE=changethis
|
|
9
|
-
GITHUB_TOKEN=changethis
|
|
10
|
-
GITHUB_USERNAME=changethis
|
|
11
|
-
GITHUB_BACKUP_REPO=changethis
|
|
12
|
-
GITHUB_DNS_REPO=changethis
|
|
13
|
-
DEFAULT_DEPLOY_ID=dd-default
|
|
14
|
-
DEFAULT_DEPLOY_HOST=default.net
|
|
15
|
-
DEFAULT_DEPLOY_PATH=/
|
|
16
|
-
MARIADB_HOST=changethis
|
|
17
|
-
MARIADB_USER=changethis
|
|
18
|
-
MARIADB_PASSWORD=changethis
|
|
19
|
-
CLOUDINARY_CLOUD_NAME=changethis
|
|
20
|
-
CLOUDINARY_API_KEY=changethis
|
|
21
|
-
CLOUDINARY_API_SECRET=changethis
|
|
22
|
-
CLOUDINARY_PASSWORD=changethis
|
|
23
|
-
CLOUDINARY_EMAIL=admin@default.net
|
|
24
|
-
DB_PG_MAAS_NAME=changethis
|
|
25
|
-
DB_PG_MAAS_PASS=changethis
|
|
26
|
-
DB_PG_MAAS_USER=changethis
|
|
27
|
-
DB_PG_MAAS_HOST=127.0.0.1
|
|
28
|
-
DB_PG_MAAS_PORT=5432
|
|
29
|
-
MAAS_ADMIN_USERNAME=changethis
|
|
30
|
-
MAAS_API_KEY=changethis
|
|
31
|
-
MAAS_ADMIN_EMAIL=admin@default.net
|
|
32
|
-
MAAS_ADMIN_PASS=changethis
|
|
33
|
-
TFTP_ROOT=changethis
|
|
34
|
-
NETMASK=255.255.255.0
|
|
35
|
-
MAAS_DNS=8.8.8.8
|
|
36
|
-
MAAS_NTP_SERVER=changethis
|
|
37
|
-
NFS_EXPORT_PATH=changethis
|
|
38
|
-
NVIDIA_API_KEY=changethis
|
|
39
|
-
DEFAULT_ADMIN_EMAIL=admin@default.net
|
|
40
|
-
DEFAULT_ADMIN_PASSWORD=changethis
|
|
41
|
-
DEFAULT_SSH_PORT=22
|
|
42
|
-
BASE_API=api
|
|
43
|
-
DEV_PROXY_PORT_OFFSET=200
|