underpost 2.8.641 → 2.8.646
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/bin/index.js +9 -9
- package/docker-compose.yml +1 -1
- package/package.json +2 -7
- package/src/cli/deploy.js +1 -1
- package/src/cli/image.js +0 -68
- package/src/cli/repository.js +5 -2
- package/src/index.js +9 -8
- package/src/server/peer.js +2 -2
- package/src/server/proxy.js +4 -4
- package/src/server/runtime.js +17 -9
- package/src/server/start.js +116 -0
package/bin/index.js
CHANGED
|
@@ -22,6 +22,15 @@ program
|
|
|
22
22
|
.description('Create a new project')
|
|
23
23
|
.action(Underpost.repo.new);
|
|
24
24
|
|
|
25
|
+
program
|
|
26
|
+
.command('start')
|
|
27
|
+
.argument('<deploy-id>', 'Deploy configuration id')
|
|
28
|
+
.argument('[env]', 'Optional environment, for default is development')
|
|
29
|
+
.option('--run', 'Run app servers and monitor health server')
|
|
30
|
+
.option('--build', 'Build app client')
|
|
31
|
+
.action(Underpost.start.callback)
|
|
32
|
+
.description('Start up server, build pipelines, or services');
|
|
33
|
+
|
|
25
34
|
program
|
|
26
35
|
.command('clone')
|
|
27
36
|
.argument(`<uri>`, 'e.g. username/repository')
|
|
@@ -125,15 +134,6 @@ program
|
|
|
125
134
|
if (args[1].init) return Underpost.secret[args[0]].init();
|
|
126
135
|
});
|
|
127
136
|
|
|
128
|
-
program
|
|
129
|
-
.command('dockerfile-node-script')
|
|
130
|
-
.argument('<deploy-id>', 'Deploy configuration id')
|
|
131
|
-
.argument('[env]', 'Optional environment, for default is development')
|
|
132
|
-
.option('--run', 'Run custom entry point script')
|
|
133
|
-
.option('--build', 'Build custom image container scripts')
|
|
134
|
-
.description('Dockerfile custom node build script')
|
|
135
|
-
.action(Underpost.image.dockerfile.script);
|
|
136
|
-
|
|
137
137
|
program
|
|
138
138
|
.command('dockerfile-image-build')
|
|
139
139
|
.option('--path [path]', 'Dockerfile path')
|
package/docker-compose.yml
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"type": "module",
|
|
3
3
|
"main": "src/index.js",
|
|
4
4
|
"name": "underpost",
|
|
5
|
-
"version": "2.8.
|
|
5
|
+
"version": "2.8.646",
|
|
6
6
|
"description": "pwa api rest template",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"start": "env-cmd -f .env.production node --max-old-space-size=8192 src/server",
|
|
@@ -118,12 +118,7 @@
|
|
|
118
118
|
"vanilla-jsoneditor": "^2.3.2",
|
|
119
119
|
"winston": "^3.11.0"
|
|
120
120
|
},
|
|
121
|
-
"devDependencies": {
|
|
122
|
-
"clean-jsdoc-theme": "^4.3.0",
|
|
123
|
-
"mocha": "^10.8.2",
|
|
124
|
-
"plantuml": "^0.0.2",
|
|
125
|
-
"swagger-autogen": "^2.23.7"
|
|
126
|
-
},
|
|
121
|
+
"devDependencies": {},
|
|
127
122
|
"publishConfig": {
|
|
128
123
|
"provenance": true,
|
|
129
124
|
"access": "public",
|
package/src/cli/deploy.js
CHANGED
|
@@ -88,7 +88,7 @@ spec:
|
|
|
88
88
|
npm install -g npm@11.2.0 &&
|
|
89
89
|
npm install -g underpost &&
|
|
90
90
|
underpost secret underpost --create-from-file /etc/config/.env.${env} &&
|
|
91
|
-
underpost
|
|
91
|
+
underpost start --build --run ${deployId} ${env}
|
|
92
92
|
volumeMounts:
|
|
93
93
|
- name: config-volume
|
|
94
94
|
mountPath: /etc/config
|
package/src/cli/image.js
CHANGED
|
@@ -60,74 +60,6 @@ class UnderpostImage {
|
|
|
60
60
|
if (podmanSave === true) shellExec(`podman save -o ${tarFile} ${podManImg}`);
|
|
61
61
|
if (kindLoad === true) shellExec(`sudo kind load image-archive ${tarFile}`);
|
|
62
62
|
},
|
|
63
|
-
async script(deployId = 'default', env = 'development', options = { run: false, build: false }) {
|
|
64
|
-
if (options.build === true) {
|
|
65
|
-
const buildBasePath = `/home/dd`;
|
|
66
|
-
const repoName = `engine-${deployId.split('-')[1]}`;
|
|
67
|
-
shellExec(`cd ${buildBasePath} && underpost clone underpostnet/${repoName}`);
|
|
68
|
-
shellExec(`cd ${buildBasePath} && sudo mv ./${repoName} ./engine`);
|
|
69
|
-
shellExec(`cd ${buildBasePath}/engine && underpost clone underpostnet/${repoName}-private`);
|
|
70
|
-
shellExec(`cd ${buildBasePath}/engine && sudo mv ./${repoName}-private ./engine-private`);
|
|
71
|
-
shellCd(`${buildBasePath}/engine`);
|
|
72
|
-
shellExec(`npm install`);
|
|
73
|
-
shellExec(`node bin/deploy conf ${deployId} ${env}`);
|
|
74
|
-
if (fs.existsSync('./engine-private/itc-scripts')) {
|
|
75
|
-
const itcScripts = await fs.readdir('./engine-private/itc-scripts');
|
|
76
|
-
for (const itcScript of itcScripts)
|
|
77
|
-
if (itcScript.match(deployId)) shellExec(`node ./engine-private/itc-scripts/${itcScript}`);
|
|
78
|
-
}
|
|
79
|
-
switch (deployId) {
|
|
80
|
-
default:
|
|
81
|
-
{
|
|
82
|
-
{
|
|
83
|
-
const originPath = `./src/db/mongo/MongooseDB.js`;
|
|
84
|
-
fs.writeFileSync(
|
|
85
|
-
originPath,
|
|
86
|
-
fs.readFileSync(originPath, 'utf8').replaceAll(
|
|
87
|
-
`connect: async (host, name) => {`,
|
|
88
|
-
`connect: async (host, name) => {
|
|
89
|
-
host = 'mongodb://mongodb-0.mongodb-service:27017';
|
|
90
|
-
`,
|
|
91
|
-
),
|
|
92
|
-
'utf8',
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
{
|
|
97
|
-
const originPath = `./src/server/valkey.js`;
|
|
98
|
-
fs.writeFileSync(
|
|
99
|
-
originPath,
|
|
100
|
-
fs.readFileSync(originPath, 'utf8').replaceAll(
|
|
101
|
-
` // port: 6379,
|
|
102
|
-
// host: 'service-valkey.default.svc.cluster.local',`,
|
|
103
|
-
` port: 6379,
|
|
104
|
-
host: 'service-valkey.default.svc.cluster.local',`,
|
|
105
|
-
),
|
|
106
|
-
'utf8',
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
break;
|
|
111
|
-
}
|
|
112
|
-
shellExec(`node bin/deploy build-full-client ${deployId}`);
|
|
113
|
-
}
|
|
114
|
-
if (options.run === true) {
|
|
115
|
-
const runCmd = env === 'production' ? 'run prod-img' : 'run dev-img';
|
|
116
|
-
if (fs.existsSync(`./engine-private/replica`)) {
|
|
117
|
-
const replicas = await fs.readdir(`./engine-private/replica`);
|
|
118
|
-
for (const replica of replicas) {
|
|
119
|
-
if (!replica.match(deployId)) continue;
|
|
120
|
-
shellExec(`node bin/deploy conf ${replica} ${env}`);
|
|
121
|
-
shellExec(`npm ${runCmd} deploy deploy-id:${replica}`, { async: true });
|
|
122
|
-
await awaitDeployMonitor(true);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
shellExec(`node bin/deploy conf ${deployId} ${env}`);
|
|
126
|
-
shellExec(`npm ${runCmd} deploy deploy-id:${deployId}`, { async: true });
|
|
127
|
-
await awaitDeployMonitor(true);
|
|
128
|
-
await UnderpostMonitor.API.callback(deployId, env, { itc: true });
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
63
|
},
|
|
132
64
|
};
|
|
133
65
|
}
|
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}`;
|
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.646';
|
|
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
|
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';
|
|
@@ -182,7 +182,11 @@ const buildRuntime = async () => {
|
|
|
182
182
|
// RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
|
|
183
183
|
// RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]
|
|
184
184
|
|
|
185
|
-
await listenPortController(
|
|
185
|
+
await UnderpostStartUp.API.listenPortController(
|
|
186
|
+
UnderpostStartUp.API.listenServerFactory(),
|
|
187
|
+
port,
|
|
188
|
+
runningData,
|
|
189
|
+
);
|
|
186
190
|
break;
|
|
187
191
|
case 'xampp':
|
|
188
192
|
if (!Xampp.enabled()) continue;
|
|
@@ -229,7 +233,11 @@ const buildRuntime = async () => {
|
|
|
229
233
|
// if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
|
|
230
234
|
// $_SERVER['HTTPS'] = 'on';
|
|
231
235
|
// }
|
|
232
|
-
await listenPortController(
|
|
236
|
+
await UnderpostStartUp.API.listenPortController(
|
|
237
|
+
UnderpostStartUp.API.listenServerFactory(),
|
|
238
|
+
port,
|
|
239
|
+
runningData,
|
|
240
|
+
);
|
|
233
241
|
break;
|
|
234
242
|
case 'nodejs':
|
|
235
243
|
const app = express();
|
|
@@ -282,7 +290,7 @@ const buildRuntime = async () => {
|
|
|
282
290
|
currentPort += 2;
|
|
283
291
|
const staticPort = newInstance(currentPort);
|
|
284
292
|
|
|
285
|
-
await listenPortController(app, staticPort, runningData);
|
|
293
|
+
await UnderpostStartUp.API.listenPortController(app, staticPort, runningData);
|
|
286
294
|
currentPort++;
|
|
287
295
|
continue;
|
|
288
296
|
}
|
|
@@ -333,7 +341,7 @@ const buildRuntime = async () => {
|
|
|
333
341
|
// }),
|
|
334
342
|
// );
|
|
335
343
|
|
|
336
|
-
await listenPortController(app, port, runningData);
|
|
344
|
+
await UnderpostStartUp.API.listenPortController(app, port, runningData);
|
|
337
345
|
break;
|
|
338
346
|
}
|
|
339
347
|
|
|
@@ -441,7 +449,7 @@ const buildRuntime = async () => {
|
|
|
441
449
|
port,
|
|
442
450
|
origins,
|
|
443
451
|
});
|
|
444
|
-
await listenPortController(listenServerFactory(), port, {
|
|
452
|
+
await UnderpostStartUp.API.listenPortController(UnderpostStartUp.API.listenServerFactory(), port, {
|
|
445
453
|
runtime: 'nodejs',
|
|
446
454
|
client: null,
|
|
447
455
|
host,
|
|
@@ -461,7 +469,7 @@ const buildRuntime = async () => {
|
|
|
461
469
|
path,
|
|
462
470
|
});
|
|
463
471
|
|
|
464
|
-
await listenPortController(peerServer, peerPort, {
|
|
472
|
+
await UnderpostStartUp.API.listenPortController(peerServer, peerPort, {
|
|
465
473
|
runtime: 'nodejs',
|
|
466
474
|
client: null,
|
|
467
475
|
host,
|
|
@@ -470,7 +478,7 @@ const buildRuntime = async () => {
|
|
|
470
478
|
});
|
|
471
479
|
}
|
|
472
480
|
|
|
473
|
-
await listenPortController(server, port, runningData);
|
|
481
|
+
await UnderpostStartUp.API.listenPortController(server, port, runningData);
|
|
474
482
|
|
|
475
483
|
break;
|
|
476
484
|
default:
|
|
@@ -483,7 +491,7 @@ const buildRuntime = async () => {
|
|
|
483
491
|
if (Xampp.enabled() && Xampp.router) Xampp.initService();
|
|
484
492
|
if (Lampp.enabled() && Lampp.router) Lampp.initService();
|
|
485
493
|
|
|
486
|
-
logRuntimeRouter();
|
|
494
|
+
UnderpostStartUp.API.logRuntimeRouter();
|
|
487
495
|
};
|
|
488
496
|
|
|
489
497
|
export { buildRuntime };
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import UnderpostDeploy from '../cli/deploy.js';
|
|
2
|
+
import UnderpostMonitor from '../cli/monitor.js';
|
|
3
|
+
import fs from 'fs-extra';
|
|
4
|
+
import { awaitDeployMonitor } from './conf.js';
|
|
5
|
+
import { actionInitLog, loggerFactory } from './logger.js';
|
|
6
|
+
import { shellCd, shellExec } from './process.js';
|
|
7
|
+
|
|
8
|
+
const logger = loggerFactory(import.meta);
|
|
9
|
+
|
|
10
|
+
class UnderpostStartUp {
|
|
11
|
+
static API = {
|
|
12
|
+
logRuntimeRouter: () => {
|
|
13
|
+
const displayLog = {};
|
|
14
|
+
|
|
15
|
+
for (const host of Object.keys(UnderpostDeploy.NETWORK))
|
|
16
|
+
for (const path of Object.keys(UnderpostDeploy.NETWORK[host]))
|
|
17
|
+
displayLog[UnderpostDeploy.NETWORK[host][path].publicHost] = UnderpostDeploy.NETWORK[host][path].local;
|
|
18
|
+
|
|
19
|
+
logger.info('Runtime network', displayLog);
|
|
20
|
+
},
|
|
21
|
+
listenServerFactory: (logic = async () => {}) => {
|
|
22
|
+
return {
|
|
23
|
+
listen: async (...args) => (
|
|
24
|
+
setTimeout(() => {
|
|
25
|
+
const message = 'Listen server factory timeout';
|
|
26
|
+
logger.error(message);
|
|
27
|
+
throw new Error(message);
|
|
28
|
+
}, 80000000), // ~ 55 days
|
|
29
|
+
(logic ? await logic(...args) : undefined, args[1]())
|
|
30
|
+
),
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
listenPortController: async (server, port, metadata) =>
|
|
34
|
+
new Promise((resolve) => {
|
|
35
|
+
try {
|
|
36
|
+
if (port === ':') {
|
|
37
|
+
server.listen(port, actionInitLog);
|
|
38
|
+
return resolve(true);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const { host, path, client, runtime, meta } = metadata;
|
|
42
|
+
const error = [];
|
|
43
|
+
if (port === undefined) error.push(`port`);
|
|
44
|
+
if (host === undefined) error.push(`host`);
|
|
45
|
+
if (path === undefined) error.push(`path`);
|
|
46
|
+
if (client === undefined) error.push(`client`);
|
|
47
|
+
if (runtime === undefined) error.push(`runtime`);
|
|
48
|
+
if (meta === undefined) error.push(`meta`);
|
|
49
|
+
if (error.length > 0) throw new Error('Listen port controller requires values: ' + error.join(', '));
|
|
50
|
+
|
|
51
|
+
server.listen(port, () => {
|
|
52
|
+
if (!UnderpostDeploy.NETWORK[host]) UnderpostDeploy.NETWORK[host] = {};
|
|
53
|
+
UnderpostDeploy.NETWORK[host][path] = {
|
|
54
|
+
meta,
|
|
55
|
+
client,
|
|
56
|
+
runtime,
|
|
57
|
+
port,
|
|
58
|
+
publicHost:
|
|
59
|
+
port === 80
|
|
60
|
+
? `http://${host}${path}`
|
|
61
|
+
: port === 443
|
|
62
|
+
? `https://${host}${path}`
|
|
63
|
+
: `http://${host}:${port}${path}`,
|
|
64
|
+
local: `http://localhost:${port}${path}`,
|
|
65
|
+
apis: metadata.apis,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
return resolve(true);
|
|
69
|
+
});
|
|
70
|
+
} catch (error) {
|
|
71
|
+
logger.error(error, { metadata, port, stack: error.stack });
|
|
72
|
+
resolve(false);
|
|
73
|
+
}
|
|
74
|
+
}),
|
|
75
|
+
|
|
76
|
+
async callback(deployId = 'default', env = 'development', options = { build: false, run: false }) {
|
|
77
|
+
if (options.build === true) await UnderpostStartUp.API.build(deployId, env);
|
|
78
|
+
if (options.run === true) await UnderpostStartUp.API.run(deployId, env);
|
|
79
|
+
},
|
|
80
|
+
async build(deployId = 'default', env = 'development') {
|
|
81
|
+
const buildBasePath = `/home/dd`;
|
|
82
|
+
const repoName = `engine-${deployId.split('-')[1]}`;
|
|
83
|
+
shellExec(`cd ${buildBasePath} && underpost clone underpostnet/${repoName}`);
|
|
84
|
+
shellExec(`cd ${buildBasePath} && sudo mv ./${repoName} ./engine`);
|
|
85
|
+
shellExec(`cd ${buildBasePath}/engine && underpost clone underpostnet/${repoName}-private`);
|
|
86
|
+
shellExec(`cd ${buildBasePath}/engine && sudo mv ./${repoName}-private ./engine-private`);
|
|
87
|
+
shellCd(`${buildBasePath}/engine`);
|
|
88
|
+
shellExec(`npm install`);
|
|
89
|
+
shellExec(`node bin/deploy conf ${deployId} ${env}`);
|
|
90
|
+
if (fs.existsSync('./engine-private/itc-scripts')) {
|
|
91
|
+
const itcScripts = await fs.readdir('./engine-private/itc-scripts');
|
|
92
|
+
for (const itcScript of itcScripts)
|
|
93
|
+
if (itcScript.match(deployId)) shellExec(`node ./engine-private/itc-scripts/${itcScript}`);
|
|
94
|
+
}
|
|
95
|
+
shellExec(`node bin/deploy build-full-client ${deployId}`);
|
|
96
|
+
},
|
|
97
|
+
async run(deployId = 'default', env = 'development') {
|
|
98
|
+
const runCmd = env === 'production' ? 'run prod-img' : 'run dev-img';
|
|
99
|
+
if (fs.existsSync(`./engine-private/replica`)) {
|
|
100
|
+
const replicas = await fs.readdir(`./engine-private/replica`);
|
|
101
|
+
for (const replica of replicas) {
|
|
102
|
+
if (!replica.match(deployId)) continue;
|
|
103
|
+
shellExec(`node bin/deploy conf ${replica} ${env}`);
|
|
104
|
+
shellExec(`npm ${runCmd} deploy deploy-id:${replica}`, { async: true });
|
|
105
|
+
await awaitDeployMonitor(true);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
shellExec(`node bin/deploy conf ${deployId} ${env}`);
|
|
109
|
+
shellExec(`npm ${runCmd} deploy deploy-id:${deployId}`, { async: true });
|
|
110
|
+
await awaitDeployMonitor(true);
|
|
111
|
+
return await UnderpostMonitor.API.callback(deployId, env);
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export default UnderpostStartUp;
|