underpost 2.8.641 → 2.8.651
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/.vscode/extensions.json +0 -1
- package/README.md +40 -2
- package/bin/deploy.js +44 -1
- package/bin/file.js +10 -0
- package/bin/index.js +1 -233
- package/cli.md +439 -0
- package/docker-compose.yml +1 -1
- package/jsdoc.json +1 -1
- package/package.json +2 -7
- package/src/api/user/user.service.js +13 -10
- package/src/cli/cluster.js +45 -2
- package/src/cli/db.js +18 -8
- package/src/cli/deploy.js +105 -53
- package/src/cli/image.js +0 -68
- package/src/cli/index.js +300 -0
- package/src/cli/monitor.js +107 -11
- package/src/cli/repository.js +5 -2
- package/src/client/components/core/Account.js +3 -3
- package/src/client/components/core/Css.js +0 -1
- package/src/client/components/core/CssCore.js +2 -0
- package/src/client/components/core/EventsUI.js +1 -1
- package/src/client/components/core/RichText.js +1 -11
- package/src/index.js +9 -8
- package/src/mailer/MailerProvider.js +3 -0
- package/src/server/client-build.js +13 -0
- package/src/server/conf.js +44 -0
- package/src/server/peer.js +2 -2
- package/src/server/proxy.js +4 -4
- package/src/server/runtime.js +22 -9
- package/src/server/start.js +123 -0
- package/src/server/valkey.js +25 -11
package/src/cli/monitor.js
CHANGED
|
@@ -4,13 +4,32 @@ import UnderpostDeploy from './deploy.js';
|
|
|
4
4
|
import axios from 'axios';
|
|
5
5
|
import UnderpostRootEnv from './env.js';
|
|
6
6
|
import fs from 'fs-extra';
|
|
7
|
+
import { shellExec } from '../server/process.js';
|
|
7
8
|
|
|
8
9
|
const logger = loggerFactory(import.meta);
|
|
9
10
|
|
|
10
11
|
class UnderpostMonitor {
|
|
11
12
|
static API = {
|
|
12
|
-
async callback(
|
|
13
|
-
|
|
13
|
+
async callback(
|
|
14
|
+
deployId,
|
|
15
|
+
env = 'development',
|
|
16
|
+
options = { now: false, single: false, msInterval: '', type: '' },
|
|
17
|
+
commanderOptions,
|
|
18
|
+
auxRouter,
|
|
19
|
+
) {
|
|
20
|
+
if (deployId === 'dd' && fs.existsSync(`./engine-private/deploy/dd.router`)) {
|
|
21
|
+
for (const _deployId of fs.readFileSync(`./engine-private/deploy/dd.router`, 'utf8').split(','))
|
|
22
|
+
UnderpostMonitor.API.callback(
|
|
23
|
+
_deployId.trim(),
|
|
24
|
+
env,
|
|
25
|
+
options,
|
|
26
|
+
commanderOptions,
|
|
27
|
+
await UnderpostDeploy.API.routerFactory(_deployId, env),
|
|
28
|
+
);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const router = auxRouter ?? (await UnderpostDeploy.API.routerFactory(deployId, env));
|
|
14
33
|
|
|
15
34
|
const confServer = loadReplicas(
|
|
16
35
|
JSON.parse(fs.readFileSync(`./engine-private/conf/${deployId}/conf.server.json`, 'utf8')),
|
|
@@ -19,20 +38,30 @@ class UnderpostMonitor {
|
|
|
19
38
|
|
|
20
39
|
const pathPortAssignmentData = pathPortAssignmentFactory(router, confServer);
|
|
21
40
|
|
|
22
|
-
logger.info(
|
|
41
|
+
logger.info(`${deployId} ${env}`, pathPortAssignmentData);
|
|
23
42
|
|
|
24
|
-
|
|
43
|
+
let errorPayloads = [];
|
|
44
|
+
let traffic = 'blue';
|
|
25
45
|
const maxAttempts = Object.keys(pathPortAssignmentData)
|
|
26
46
|
.map((host) => pathPortAssignmentData[host].length)
|
|
27
47
|
.reduce((accumulator, value) => accumulator + value, 0);
|
|
28
48
|
|
|
29
49
|
const monitor = async (reject) => {
|
|
30
|
-
logger.info(
|
|
50
|
+
logger.info(`[${deployId}-${env}] Check server health`);
|
|
31
51
|
for (const host of Object.keys(pathPortAssignmentData)) {
|
|
32
52
|
for (const instance of pathPortAssignmentData[host]) {
|
|
33
53
|
const { port, path } = instance;
|
|
34
54
|
if (path.match('peer') || path.match('socket')) continue;
|
|
35
|
-
|
|
55
|
+
let urlTest = `http://localhost:${port}${path}`;
|
|
56
|
+
switch (options.type) {
|
|
57
|
+
case 'remote':
|
|
58
|
+
case 'blue-green':
|
|
59
|
+
urlTest = `https://${host}${path}`;
|
|
60
|
+
break;
|
|
61
|
+
|
|
62
|
+
default:
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
36
65
|
// logger.info('Test instance', urlTest);
|
|
37
66
|
await axios.get(urlTest, { timeout: 10000 }).catch((error) => {
|
|
38
67
|
// console.log(error);
|
|
@@ -50,8 +79,42 @@ class UnderpostMonitor {
|
|
|
50
79
|
errorPayloads.push(errorPayload);
|
|
51
80
|
if (errorPayloads.length >= maxAttempts) {
|
|
52
81
|
const message = JSON.stringify(errorPayloads, null, 4);
|
|
53
|
-
|
|
54
|
-
|
|
82
|
+
logger.error(
|
|
83
|
+
`Deployment ${deployId} ${env} has been reached max attempts error payloads`,
|
|
84
|
+
errorPayloads,
|
|
85
|
+
);
|
|
86
|
+
switch (options.type) {
|
|
87
|
+
case 'blue-green':
|
|
88
|
+
{
|
|
89
|
+
const confServer = JSON.parse(
|
|
90
|
+
fs.readFileSync(`./engine-private/conf/${deployId}/conf.server.json`, 'utf8'),
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
for (const host of Object.keys(confServer)) {
|
|
94
|
+
shellExec(`sudo kubectl delete HTTPProxy ${host}`);
|
|
95
|
+
}
|
|
96
|
+
shellExec(`sudo kubectl rollout restart deployment/${deployId}-${env}-${traffic}`);
|
|
97
|
+
|
|
98
|
+
if (traffic === 'blue') traffic = 'green';
|
|
99
|
+
else traffic = 'blue';
|
|
100
|
+
|
|
101
|
+
shellExec(
|
|
102
|
+
`node bin deploy --info-router --build-manifest --traffic ${traffic} ${deployId} ${env}`,
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
shellExec(`sudo kubectl apply -f ./engine-private/conf/${deployId}/build/${env}/proxy.yaml`);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
break;
|
|
109
|
+
|
|
110
|
+
case 'remote':
|
|
111
|
+
break;
|
|
112
|
+
|
|
113
|
+
default:
|
|
114
|
+
if (reject) reject(message);
|
|
115
|
+
else throw new Error(message);
|
|
116
|
+
}
|
|
117
|
+
errorPayloads = [];
|
|
55
118
|
}
|
|
56
119
|
logger.error('Error accumulator', errorPayloads.length);
|
|
57
120
|
}
|
|
@@ -63,11 +126,44 @@ class UnderpostMonitor {
|
|
|
63
126
|
if (options.single === true) return;
|
|
64
127
|
let optionsMsTimeout = parseInt(options.msInterval);
|
|
65
128
|
if (isNaN(optionsMsTimeout)) optionsMsTimeout = 30000;
|
|
129
|
+
let monitorTrafficName;
|
|
130
|
+
let monitorPodName;
|
|
66
131
|
const monitorCallBack = (resolve, reject) => {
|
|
67
|
-
const envMsTimeout = UnderpostRootEnv.API.get(
|
|
132
|
+
const envMsTimeout = UnderpostRootEnv.API.get(`${deployId}-${env}-monitor-ms`);
|
|
68
133
|
setTimeout(
|
|
69
134
|
async () => {
|
|
70
|
-
switch (
|
|
135
|
+
switch (options.type) {
|
|
136
|
+
case 'blue-green':
|
|
137
|
+
{
|
|
138
|
+
if (monitorTrafficName !== traffic) {
|
|
139
|
+
monitorTrafficName = undefined;
|
|
140
|
+
monitorPodName = undefined;
|
|
141
|
+
}
|
|
142
|
+
const cmd = `underpost config get container-status`;
|
|
143
|
+
const checkDeploymentReadyStatus = () => {
|
|
144
|
+
const [podName] = UnderpostDeploy.API.get(`${deployId}-${env}-${traffic}`);
|
|
145
|
+
if (
|
|
146
|
+
shellExec(`sudo kubectl exec -i ${podName} -- sh -c "${cmd}"`, { stdout: true }).match(
|
|
147
|
+
`${deployId}-${env}-running-deployment`,
|
|
148
|
+
)
|
|
149
|
+
) {
|
|
150
|
+
monitorPodName = podName;
|
|
151
|
+
monitorTrafficName = `${traffic}`;
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
if (!monitorPodName) {
|
|
155
|
+
checkDeploymentReadyStatus();
|
|
156
|
+
monitorCallBack(resolve, reject);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
break;
|
|
162
|
+
|
|
163
|
+
default:
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
switch (UnderpostRootEnv.API.get(`${deployId}-${env}-monitor-input`)) {
|
|
71
167
|
case 'pause':
|
|
72
168
|
monitorCallBack(resolve, reject);
|
|
73
169
|
return;
|
|
@@ -84,7 +180,7 @@ class UnderpostMonitor {
|
|
|
84
180
|
!isNaN(envMsTimeout) ? envMsTimeout : optionsMsTimeout,
|
|
85
181
|
);
|
|
86
182
|
};
|
|
87
|
-
return
|
|
183
|
+
return new Promise((...args) => monitorCallBack(...args));
|
|
88
184
|
},
|
|
89
185
|
};
|
|
90
186
|
}
|
package/src/cli/repository.js
CHANGED
|
@@ -4,7 +4,7 @@ import { pbcopy, shellExec } from '../server/process.js';
|
|
|
4
4
|
import { actionInitLog, loggerFactory } from '../server/logger.js';
|
|
5
5
|
import fs from 'fs-extra';
|
|
6
6
|
import { getNpmRootPath } from '../server/conf.js';
|
|
7
|
-
import
|
|
7
|
+
import UnderpostStartUp from '../server/start.js';
|
|
8
8
|
|
|
9
9
|
dotenv.config();
|
|
10
10
|
|
|
@@ -78,7 +78,10 @@ class UnderpostRepository {
|
|
|
78
78
|
return new Promise(async (resolve, reject) => {
|
|
79
79
|
try {
|
|
80
80
|
await logger.setUpInfo();
|
|
81
|
-
if (repositoryName === 'service')
|
|
81
|
+
if (repositoryName === 'service')
|
|
82
|
+
return resolve(
|
|
83
|
+
await UnderpostStartUp.API.listenPortController(UnderpostStartUp.API.listenServerFactory(), ':'),
|
|
84
|
+
);
|
|
82
85
|
else actionInitLog();
|
|
83
86
|
const exeRootPath = `${getNpmRootPath()}/underpost`;
|
|
84
87
|
const destFolder = `./${repositoryName}`;
|
|
@@ -204,7 +204,7 @@ const Account = {
|
|
|
204
204
|
disabled: false,
|
|
205
205
|
extension: async () =>
|
|
206
206
|
html`${await BtnIcon.Render({
|
|
207
|
-
class: `wfa btn-input-extension btn-account-update-username`,
|
|
207
|
+
class: `in wfa btn-input-extension btn-account-update-username`,
|
|
208
208
|
type: 'button',
|
|
209
209
|
style: 'text-align: left',
|
|
210
210
|
label: html`${Translate.Render(`update`)}`,
|
|
@@ -223,7 +223,7 @@ const Account = {
|
|
|
223
223
|
extension: !(options && options.disabled && options.disabled.includes('emailConfirm'))
|
|
224
224
|
? async () => html`<div class="in verify-email-status"></div>
|
|
225
225
|
${await BtnIcon.Render({
|
|
226
|
-
class: `wfa btn-input-extension btn-confirm-email`,
|
|
226
|
+
class: `in wfa btn-input-extension btn-confirm-email`,
|
|
227
227
|
type: 'button',
|
|
228
228
|
style: 'text-align: left',
|
|
229
229
|
label: html`<div class="in">
|
|
@@ -246,7 +246,7 @@ const Account = {
|
|
|
246
246
|
disabledEye: true,
|
|
247
247
|
extension: async () =>
|
|
248
248
|
html`${await BtnIcon.Render({
|
|
249
|
-
class: `wfa btn-input-extension btn-account-change-password`,
|
|
249
|
+
class: `in wfa btn-input-extension btn-account-change-password`,
|
|
250
250
|
type: 'button',
|
|
251
251
|
style: 'text-align: left',
|
|
252
252
|
label: html`${Translate.Render(`change-password`)}`,
|
|
@@ -761,7 +761,6 @@ const renderWave = ({ id }) => {
|
|
|
761
761
|
const cssTokensEffect = {};
|
|
762
762
|
const cssTokensContainer = {};
|
|
763
763
|
const cssEffect = async (containerSelector, event) => {
|
|
764
|
-
return;
|
|
765
764
|
// Array.from(event.target.classList)
|
|
766
765
|
let offsetX, offsetY;
|
|
767
766
|
if (Array.from(event.srcElement.classList).includes('ripple') && cssTokensContainer[containerSelector]) {
|
|
@@ -524,6 +524,7 @@ const CssCoreDark = {
|
|
|
524
524
|
margin: 5px 0 0 0;
|
|
525
525
|
padding: 5px;
|
|
526
526
|
font-size: 16px;
|
|
527
|
+
min-height: 40px;
|
|
527
528
|
}
|
|
528
529
|
.btn-input-extension:hover {
|
|
529
530
|
}
|
|
@@ -843,6 +844,7 @@ const CssCoreLight = {
|
|
|
843
844
|
margin: 5px 0 0 0;
|
|
844
845
|
padding: 5px;
|
|
845
846
|
font-size: 16px;
|
|
847
|
+
min-height: 40px;
|
|
846
848
|
}
|
|
847
849
|
.btn-input-extension:hover {
|
|
848
850
|
}
|
|
@@ -12,7 +12,7 @@ const EventsUI = {
|
|
|
12
12
|
if (!s(id)) return;
|
|
13
13
|
let complete = true;
|
|
14
14
|
s(id)[type] = async function (e) {
|
|
15
|
-
cssEffect(id, e);
|
|
15
|
+
if (options.clickEffect) cssEffect(id, e);
|
|
16
16
|
if (complete) {
|
|
17
17
|
complete = false;
|
|
18
18
|
await LoadingAnimation.spinner.play(loadingContainer ? loadingContainer : id);
|
|
@@ -7,28 +7,18 @@ const RichText = {
|
|
|
7
7
|
Render: async function (options = { id: '', parentIdModal: '' }) {
|
|
8
8
|
const id = options?.id ? options.id : getId(this.Tokens, 'rich-text-');
|
|
9
9
|
this.Tokens[id] = {};
|
|
10
|
-
let top, height;
|
|
11
10
|
setTimeout(() => {
|
|
12
11
|
const easyMDE = new EasyMDE({
|
|
13
12
|
element: s(`.${id}`),
|
|
13
|
+
hideIcons: ['fullscreen', 'side-by-side'],
|
|
14
14
|
onToggleFullScreen: (onFs) => {
|
|
15
15
|
if (onFs) {
|
|
16
16
|
if (options.parentIdModal) {
|
|
17
|
-
s(`.btn-bar-modal-container-${options.parentIdModal}`).classList.add('hide');
|
|
18
|
-
top = newInstance(s(`.${options.parentIdModal}`).style.top);
|
|
19
|
-
height = newInstance(s(`.${options.parentIdModal}`).style.height);
|
|
20
|
-
s(`.${options.parentIdModal}`).style.top = '0px';
|
|
21
|
-
s(`.${options.parentIdModal}`).style.height = `${window.innerHeight}px`;
|
|
22
17
|
}
|
|
23
18
|
// Modal.cleanUI();
|
|
24
|
-
if (s(`.slide-menu-top-bar`)) s(`.slide-menu-top-bar`).classList.add('hide');
|
|
25
19
|
} else {
|
|
26
20
|
if (options.parentIdModal) {
|
|
27
|
-
s(`.btn-bar-modal-container-${options.parentIdModal}`).classList.remove('hide');
|
|
28
|
-
s(`.${options.parentIdModal}`).style.top = top;
|
|
29
|
-
s(`.${options.parentIdModal}`).style.height = height;
|
|
30
21
|
}
|
|
31
|
-
if (s(`.slide-menu-top-bar`)) s(`.slide-menu-top-bar`).classList.add('remove');
|
|
32
22
|
// Modal.restoreUI();
|
|
33
23
|
}
|
|
34
24
|
},
|
package/src/index.js
CHANGED
|
@@ -16,6 +16,7 @@ import UnderpostRepository from './cli/repository.js';
|
|
|
16
16
|
import UnderpostScript from './cli/script.js';
|
|
17
17
|
import UnderpostSecret from './cli/secrets.js';
|
|
18
18
|
import UnderpostTest from './cli/test.js';
|
|
19
|
+
import UnderpostStartUp from './server/start.js';
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* Underpost main module methods
|
|
@@ -29,7 +30,7 @@ class Underpost {
|
|
|
29
30
|
* @type {String}
|
|
30
31
|
* @memberof Underpost
|
|
31
32
|
*/
|
|
32
|
-
static version = 'v2.8.
|
|
33
|
+
static version = 'v2.8.651';
|
|
33
34
|
/**
|
|
34
35
|
* Repository cli API
|
|
35
36
|
* @static
|
|
@@ -51,6 +52,13 @@ class Underpost {
|
|
|
51
52
|
* @memberof Underpost
|
|
52
53
|
*/
|
|
53
54
|
static test = UnderpostTest.API;
|
|
55
|
+
/**
|
|
56
|
+
* Underpost Start Up cli API
|
|
57
|
+
* @static
|
|
58
|
+
* @type {UnderpostStartUp.API}
|
|
59
|
+
* @memberof Underpost
|
|
60
|
+
*/
|
|
61
|
+
static start = UnderpostStartUp.API;
|
|
54
62
|
/**
|
|
55
63
|
* Cluster cli API
|
|
56
64
|
* @static
|
|
@@ -93,13 +101,6 @@ class Underpost {
|
|
|
93
101
|
* @memberof Underpost
|
|
94
102
|
*/
|
|
95
103
|
static deploy = UnderpostDeploy.API;
|
|
96
|
-
/**
|
|
97
|
-
* Deployment cli NETWORK
|
|
98
|
-
* @static
|
|
99
|
-
* @type {UnderpostDeploy.NETWORK}
|
|
100
|
-
* @memberof Underpost
|
|
101
|
-
*/
|
|
102
|
-
static deployNetwork = UnderpostDeploy.NETWORK;
|
|
103
104
|
/**
|
|
104
105
|
* Cron cli API
|
|
105
106
|
* @static
|
|
@@ -32,6 +32,9 @@ const MailerProvider = {
|
|
|
32
32
|
},
|
|
33
33
|
) {
|
|
34
34
|
try {
|
|
35
|
+
options.transport.tls = {
|
|
36
|
+
rejectUnauthorized: false,
|
|
37
|
+
};
|
|
35
38
|
const { id } = options;
|
|
36
39
|
// Generate test SMTP service account from ethereal.email
|
|
37
40
|
// Only needed if you don't have a real mail account for testing
|
|
@@ -683,6 +683,19 @@ Sitemap: https://${host}${path === '/' ? '' : path}/sitemap.xml`,
|
|
|
683
683
|
root file where the route starts, such as index.js, app.js, routes.js, etc ... */
|
|
684
684
|
|
|
685
685
|
await swaggerAutoGen({ openapi: '3.0.0' })(outputFile, routes, doc);
|
|
686
|
+
|
|
687
|
+
const htmlFiles = await fs.readdir(`./public/${host}/docs/engine/${Underpost.version.replace('v', '')}`);
|
|
688
|
+
for (const htmlFile of htmlFiles) {
|
|
689
|
+
if (htmlFile.match('.html')) {
|
|
690
|
+
fs.writeFileSync(
|
|
691
|
+
`./public/${host}/docs/engine/${Underpost.version.replace('v', '')}/${htmlFile}`,
|
|
692
|
+
fs
|
|
693
|
+
.readFileSync(`./public/${host}/docs/engine/${Underpost.version.replace('v', '')}/${htmlFile}`, 'utf8')
|
|
694
|
+
.replaceAll('Tutorials', 'References'),
|
|
695
|
+
'utf8',
|
|
696
|
+
);
|
|
697
|
+
}
|
|
698
|
+
}
|
|
686
699
|
}
|
|
687
700
|
|
|
688
701
|
if (client) {
|
package/src/server/conf.js
CHANGED
|
@@ -923,6 +923,49 @@ const mergeFile = async (parts = [], outputFilePath) => {
|
|
|
923
923
|
});
|
|
924
924
|
};
|
|
925
925
|
|
|
926
|
+
const rebuildConfFactory = ({ deployId, valkey, mongo }) => {
|
|
927
|
+
const confServer = loadReplicas(
|
|
928
|
+
JSON.parse(fs.readFileSync(`./engine-private/conf/${deployId}/conf.server.json`, 'utf8')),
|
|
929
|
+
);
|
|
930
|
+
for (const host of Object.keys(confServer)) {
|
|
931
|
+
for (const path of Object.keys(confServer[host])) {
|
|
932
|
+
if (!confServer[host][path].db) continue;
|
|
933
|
+
const { singleReplica, replicas, db } = confServer[host][path];
|
|
934
|
+
const { provider } = db;
|
|
935
|
+
if (singleReplica) {
|
|
936
|
+
for (const replica of replicas) {
|
|
937
|
+
const deployIdReplica = buildReplicaId({ replica, deployId });
|
|
938
|
+
const confServerReplica = JSON.parse(
|
|
939
|
+
fs.readFileSync(`./engine-private/replica/${deployIdReplica}/conf.server.json`, 'utf8'),
|
|
940
|
+
);
|
|
941
|
+
for (const _host of Object.keys(confServerReplica)) {
|
|
942
|
+
for (const _path of Object.keys(confServerReplica[_host])) {
|
|
943
|
+
confServerReplica[_host][_path].valkey = valkey;
|
|
944
|
+
switch (provider) {
|
|
945
|
+
case 'mongoose':
|
|
946
|
+
confServerReplica[_host][_path].db.host = mongo.host;
|
|
947
|
+
break;
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
fs.writeFileSync(
|
|
952
|
+
`./engine-private/replica/${deployIdReplica}/conf.server.json`,
|
|
953
|
+
JSON.stringify(confServerReplica, null, 4),
|
|
954
|
+
'utf8',
|
|
955
|
+
);
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
confServer[host][path].valkey = valkey;
|
|
959
|
+
switch (provider) {
|
|
960
|
+
case 'mongoose':
|
|
961
|
+
confServer[host][path].db.host = mongo.host;
|
|
962
|
+
break;
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
fs.writeFileSync(`./engine-private/conf/${deployId}/conf.server.json`, JSON.stringify(confServer, null, 4), 'utf8');
|
|
967
|
+
};
|
|
968
|
+
|
|
926
969
|
const getRestoreCronCmd = async (options = { host: '', path: '', conf: {}, deployId: '' }) => {
|
|
927
970
|
const { host, path, conf, deployId } = options;
|
|
928
971
|
const { runtime, db, git, directory } = conf[host][path];
|
|
@@ -1166,4 +1209,5 @@ export {
|
|
|
1166
1209
|
pathPortAssignmentFactory,
|
|
1167
1210
|
deployRangePortFactory,
|
|
1168
1211
|
awaitDeployMonitor,
|
|
1212
|
+
rebuildConfFactory,
|
|
1169
1213
|
};
|
package/src/server/peer.js
CHANGED
|
@@ -2,7 +2,7 @@ import { PeerServer } from 'peer';
|
|
|
2
2
|
import dotenv from 'dotenv';
|
|
3
3
|
import { loggerFactory } from './logger.js';
|
|
4
4
|
import fs from 'fs-extra';
|
|
5
|
-
import
|
|
5
|
+
import UnderpostStartUp from './start.js';
|
|
6
6
|
|
|
7
7
|
dotenv.config();
|
|
8
8
|
|
|
@@ -25,7 +25,7 @@ const createPeerServer = async ({ port, devPort, origins, host, path }) => {
|
|
|
25
25
|
// cert: fs.readFileSync(''),
|
|
26
26
|
// ca: fs.readFileSync(''),
|
|
27
27
|
};
|
|
28
|
-
const peerServer = listenServerFactory(() => PeerServer(options));
|
|
28
|
+
const peerServer = UnderpostStartUp.API.listenServerFactory(() => PeerServer(options));
|
|
29
29
|
|
|
30
30
|
return { options, peerServer, meta: import.meta };
|
|
31
31
|
};
|
package/src/server/proxy.js
CHANGED
|
@@ -5,9 +5,9 @@ import dotenv from 'dotenv';
|
|
|
5
5
|
|
|
6
6
|
import { createProxyMiddleware } from 'http-proxy-middleware';
|
|
7
7
|
import { loggerFactory, loggerMiddleware } from './logger.js';
|
|
8
|
-
import { listenPortController } from './network.js';
|
|
9
8
|
import { createSslServer, sslRedirectMiddleware } from './ssl.js';
|
|
10
9
|
import { buildPortProxyRouter, buildProxyRouter, maintenanceMiddleware } from './conf.js';
|
|
10
|
+
import UnderpostStartUp from './start.js';
|
|
11
11
|
|
|
12
12
|
dotenv.config();
|
|
13
13
|
|
|
@@ -71,11 +71,11 @@ const buildProxy = async () => {
|
|
|
71
71
|
switch (port) {
|
|
72
72
|
case 443:
|
|
73
73
|
const { ServerSSL } = await createSslServer(app, hosts);
|
|
74
|
-
await listenPortController(ServerSSL, port, runningData);
|
|
74
|
+
await UnderpostStartUp.API.listenPortController(ServerSSL, port, runningData);
|
|
75
75
|
break;
|
|
76
76
|
|
|
77
77
|
default:
|
|
78
|
-
await listenPortController(app, port, runningData);
|
|
78
|
+
await UnderpostStartUp.API.listenPortController(app, port, runningData);
|
|
79
79
|
|
|
80
80
|
break;
|
|
81
81
|
}
|
|
@@ -83,7 +83,7 @@ const buildProxy = async () => {
|
|
|
83
83
|
break;
|
|
84
84
|
|
|
85
85
|
default:
|
|
86
|
-
await listenPortController(app, port, runningData);
|
|
86
|
+
await UnderpostStartUp.API.listenPortController(app, port, runningData);
|
|
87
87
|
|
|
88
88
|
break;
|
|
89
89
|
}
|
package/src/server/runtime.js
CHANGED
|
@@ -9,7 +9,7 @@ import compression from 'compression';
|
|
|
9
9
|
|
|
10
10
|
import { createServer } from 'http';
|
|
11
11
|
import { getRootDirectory } from './process.js';
|
|
12
|
-
import
|
|
12
|
+
import UnderpostStartUp from './start.js';
|
|
13
13
|
import { loggerFactory, loggerMiddleware } from './logger.js';
|
|
14
14
|
import { getCapVariableName, newInstance } from '../client/components/core/CommonJs.js';
|
|
15
15
|
import { Xampp } from '../runtime/xampp/Xampp.js';
|
|
@@ -21,6 +21,7 @@ import { Lampp } from '../runtime/lampp/Lampp.js';
|
|
|
21
21
|
import { getDeployId } from './conf.js';
|
|
22
22
|
import { JSONweb, ssrFactory } from './client-formatted.js';
|
|
23
23
|
import Underpost from '../index.js';
|
|
24
|
+
import { createValkeyConnection } from './valkey.js';
|
|
24
25
|
|
|
25
26
|
dotenv.config();
|
|
26
27
|
|
|
@@ -67,6 +68,7 @@ const buildRuntime = async () => {
|
|
|
67
68
|
peer,
|
|
68
69
|
singleReplica,
|
|
69
70
|
replicas,
|
|
71
|
+
valkey,
|
|
70
72
|
} = confServer[host][path];
|
|
71
73
|
|
|
72
74
|
if (singleReplica && replicas && replicas.length > 0 && !singleReplicaHosts.includes(host)) {
|
|
@@ -182,7 +184,11 @@ const buildRuntime = async () => {
|
|
|
182
184
|
// RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
|
|
183
185
|
// RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]
|
|
184
186
|
|
|
185
|
-
await listenPortController(
|
|
187
|
+
await UnderpostStartUp.API.listenPortController(
|
|
188
|
+
UnderpostStartUp.API.listenServerFactory(),
|
|
189
|
+
port,
|
|
190
|
+
runningData,
|
|
191
|
+
);
|
|
186
192
|
break;
|
|
187
193
|
case 'xampp':
|
|
188
194
|
if (!Xampp.enabled()) continue;
|
|
@@ -229,7 +235,11 @@ const buildRuntime = async () => {
|
|
|
229
235
|
// if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
|
|
230
236
|
// $_SERVER['HTTPS'] = 'on';
|
|
231
237
|
// }
|
|
232
|
-
await listenPortController(
|
|
238
|
+
await UnderpostStartUp.API.listenPortController(
|
|
239
|
+
UnderpostStartUp.API.listenServerFactory(),
|
|
240
|
+
port,
|
|
241
|
+
runningData,
|
|
242
|
+
);
|
|
233
243
|
break;
|
|
234
244
|
case 'nodejs':
|
|
235
245
|
const app = express();
|
|
@@ -282,7 +292,7 @@ const buildRuntime = async () => {
|
|
|
282
292
|
currentPort += 2;
|
|
283
293
|
const staticPort = newInstance(currentPort);
|
|
284
294
|
|
|
285
|
-
await listenPortController(app, staticPort, runningData);
|
|
295
|
+
await UnderpostStartUp.API.listenPortController(app, staticPort, runningData);
|
|
286
296
|
currentPort++;
|
|
287
297
|
continue;
|
|
288
298
|
}
|
|
@@ -333,7 +343,7 @@ const buildRuntime = async () => {
|
|
|
333
343
|
// }),
|
|
334
344
|
// );
|
|
335
345
|
|
|
336
|
-
await listenPortController(app, port, runningData);
|
|
346
|
+
await UnderpostStartUp.API.listenPortController(app, port, runningData);
|
|
337
347
|
break;
|
|
338
348
|
}
|
|
339
349
|
|
|
@@ -353,6 +363,9 @@ const buildRuntime = async () => {
|
|
|
353
363
|
|
|
354
364
|
if (db && apis) await DataBaseProvider.load({ apis, host, path, db });
|
|
355
365
|
|
|
366
|
+
// valkey server
|
|
367
|
+
await createValkeyConnection({ host, path }, valkey);
|
|
368
|
+
|
|
356
369
|
if (mailer) {
|
|
357
370
|
const mailerSsrConf = confSSR[getCapVariableName(client)];
|
|
358
371
|
await MailerProvider.load({
|
|
@@ -441,7 +454,7 @@ const buildRuntime = async () => {
|
|
|
441
454
|
port,
|
|
442
455
|
origins,
|
|
443
456
|
});
|
|
444
|
-
await listenPortController(listenServerFactory(), port, {
|
|
457
|
+
await UnderpostStartUp.API.listenPortController(UnderpostStartUp.API.listenServerFactory(), port, {
|
|
445
458
|
runtime: 'nodejs',
|
|
446
459
|
client: null,
|
|
447
460
|
host,
|
|
@@ -461,7 +474,7 @@ const buildRuntime = async () => {
|
|
|
461
474
|
path,
|
|
462
475
|
});
|
|
463
476
|
|
|
464
|
-
await listenPortController(peerServer, peerPort, {
|
|
477
|
+
await UnderpostStartUp.API.listenPortController(peerServer, peerPort, {
|
|
465
478
|
runtime: 'nodejs',
|
|
466
479
|
client: null,
|
|
467
480
|
host,
|
|
@@ -470,7 +483,7 @@ const buildRuntime = async () => {
|
|
|
470
483
|
});
|
|
471
484
|
}
|
|
472
485
|
|
|
473
|
-
await listenPortController(server, port, runningData);
|
|
486
|
+
await UnderpostStartUp.API.listenPortController(server, port, runningData);
|
|
474
487
|
|
|
475
488
|
break;
|
|
476
489
|
default:
|
|
@@ -483,7 +496,7 @@ const buildRuntime = async () => {
|
|
|
483
496
|
if (Xampp.enabled() && Xampp.router) Xampp.initService();
|
|
484
497
|
if (Lampp.enabled() && Lampp.router) Lampp.initService();
|
|
485
498
|
|
|
486
|
-
logRuntimeRouter();
|
|
499
|
+
UnderpostStartUp.API.logRuntimeRouter();
|
|
487
500
|
};
|
|
488
501
|
|
|
489
502
|
export { buildRuntime };
|