underpost 2.8.637 → 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/build.js +1 -1
- package/bin/deploy.js +2 -1
- package/bin/index.js +11 -9
- package/docker-compose.yml +1 -1
- package/package.json +2 -9
- package/src/api/default/default.service.js +1 -1
- package/src/api/user/user.service.js +1 -1
- package/src/cli/cron.js +39 -8
- package/src/cli/deploy.js +64 -11
- package/src/cli/image.js +0 -70
- package/src/cli/repository.js +5 -2
- package/src/client/components/core/Account.js +22 -18
- package/src/client/components/core/CalendarCore.js +13 -85
- package/src/client/components/core/CommonJs.js +2 -1
- package/src/client/components/core/EventsUI.js +2 -2
- package/src/client/components/core/FileExplorer.js +86 -78
- package/src/client/components/core/Modal.js +12 -7
- package/src/client/components/core/Panel.js +14 -56
- package/src/client/components/core/PanelForm.js +13 -24
- package/src/client/components/core/Router.js +3 -1
- package/src/client/components/default/RoutesDefault.js +3 -2
- package/src/client/services/default/default.management.js +45 -38
- package/src/index.js +11 -3
- package/src/server/dns.js +9 -1
- package/src/server/json-schema.js +77 -0
- package/src/server/network.js +7 -122
- package/src/server/peer.js +2 -2
- package/src/server/proxy.js +4 -4
- package/src/server/runtime.js +17 -11
- package/src/server/start.js +116 -0
|
@@ -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;
|