@underpostnet/underpost 2.98.3 → 2.99.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.development +1 -0
- package/.env.production +1 -0
- package/.env.test +1 -0
- package/README.md +2 -3
- package/bin/deploy.js +1 -1
- package/cli.md +113 -110
- package/manifests/deployment/dd-default-development/deployment.yaml +2 -2
- package/manifests/deployment/dd-test-development/deployment.yaml +4 -4
- package/package.json +1 -2
- package/src/api/user/user.router.js +7 -40
- package/src/cli/baremetal.js +67 -71
- package/src/cli/cloud-init.js +11 -12
- package/src/cli/cluster.js +22 -24
- package/src/cli/db.js +43 -50
- package/src/cli/deploy.js +163 -61
- package/src/cli/env.js +20 -5
- package/src/cli/fs.js +19 -21
- package/src/cli/index.js +38 -32
- package/src/cli/lxd.js +5 -5
- package/src/cli/monitor.js +83 -88
- package/src/cli/repository.js +7 -6
- package/src/cli/run.js +498 -288
- package/src/cli/secrets.js +3 -3
- package/src/cli/ssh.js +80 -32
- package/src/cli/static.js +1 -1
- package/src/cli/test.js +6 -7
- package/src/index.js +49 -32
- package/src/runtime/express/Express.js +7 -6
- package/src/server/auth.js +6 -1
- package/src/server/backup.js +11 -1
- package/src/server/conf.js +4 -4
- package/src/{cli → server}/cron.js +56 -29
- package/src/server/dns.js +39 -31
- package/src/server/peer.js +2 -2
- package/src/server/process.js +2 -2
- package/src/server/proxy.js +8 -7
- package/src/server/runtime.js +4 -7
- package/src/server/start.js +28 -15
- package/src/ws/IoServer.js +2 -3
- package/scripts/ssh-cluster-info.sh +0 -15
- package/src/cli/script.js +0 -85
- package/src/monitor.js +0 -34
package/src/cli/script.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Script module for managing the execution of scripts.
|
|
3
|
-
* @module src/cli/script.js
|
|
4
|
-
* @namespace UnderpostScript
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { getNpmRootPath } from '../server/conf.js';
|
|
8
|
-
import { loggerFactory } from '../server/logger.js';
|
|
9
|
-
import { shellExec } from '../server/process.js';
|
|
10
|
-
import fs from 'fs-extra';
|
|
11
|
-
import UnderpostDeploy from './deploy.js';
|
|
12
|
-
|
|
13
|
-
const logger = loggerFactory(import.meta);
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @class UnderpostScript
|
|
17
|
-
* @description Manages the execution of scripts.
|
|
18
|
-
* @memberof UnderpostScript
|
|
19
|
-
*/
|
|
20
|
-
class UnderpostScript {
|
|
21
|
-
static API = {
|
|
22
|
-
/**
|
|
23
|
-
* @method set
|
|
24
|
-
* @description Sets a script in the package.json file.
|
|
25
|
-
* @param {string} key - The key for the script.
|
|
26
|
-
* @param {string} value - The value for the script.
|
|
27
|
-
* @memberof UnderpostScript
|
|
28
|
-
*/
|
|
29
|
-
set(key, value) {
|
|
30
|
-
const npmRoot = `${getNpmRootPath()}/underpost`;
|
|
31
|
-
const packageJson = JSON.parse(fs.readFileSync(`${npmRoot}/package.json`, 'utf8'));
|
|
32
|
-
packageJson.scripts[key] = value;
|
|
33
|
-
fs.writeFileSync(`${npmRoot}/package.json`, JSON.stringify(packageJson, null, 4));
|
|
34
|
-
},
|
|
35
|
-
/**
|
|
36
|
-
* @method run
|
|
37
|
-
* @description Runs a script.
|
|
38
|
-
* @param {string} key - The key for the script.
|
|
39
|
-
* @param {string} value - The value for the script.
|
|
40
|
-
* @param {object} options - The options for the script.
|
|
41
|
-
* @memberof UnderpostScript
|
|
42
|
-
*/
|
|
43
|
-
run(key, value, options) {
|
|
44
|
-
const npmRoot = `${getNpmRootPath()}/underpost`;
|
|
45
|
-
const packageJson = JSON.parse(fs.readFileSync(`${npmRoot}/package.json`, 'utf8'));
|
|
46
|
-
if (options.itc === true) {
|
|
47
|
-
value = packageJson.scripts[key];
|
|
48
|
-
const podScriptPath = `${options.itcPath && typeof options.itcPath === 'string' ? options.itcPath : '/'}${value
|
|
49
|
-
.split('/')
|
|
50
|
-
.pop()}`;
|
|
51
|
-
const nameSpace = options.ns && typeof options.ns === 'string' ? options.ns : 'default';
|
|
52
|
-
const podMatch = options.podName && typeof options.podName === 'string' ? options.podName : key;
|
|
53
|
-
|
|
54
|
-
if (fs.existsSync(`${value}`)) {
|
|
55
|
-
for (const pod of UnderpostDeploy.API.get(podMatch)) {
|
|
56
|
-
shellExec(`sudo kubectl cp ${value} ${nameSpace}/${pod.NAME}:${podScriptPath}`);
|
|
57
|
-
const cmd = `node ${podScriptPath}`;
|
|
58
|
-
shellExec(`sudo kubectl exec -i ${pod.NAME} -- sh -c "${cmd}"`);
|
|
59
|
-
}
|
|
60
|
-
} else {
|
|
61
|
-
for (const pod of UnderpostDeploy.API.get(podMatch)) {
|
|
62
|
-
shellExec(`sudo kubectl exec -i ${pod.NAME} -- sh -c "${value}"`);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
shellExec(`cd ${npmRoot} && npm run ${key}`);
|
|
69
|
-
},
|
|
70
|
-
/**
|
|
71
|
-
* @method get
|
|
72
|
-
* @description Gets a script from the package.json file.
|
|
73
|
-
* @param {string} key - The key for the script.
|
|
74
|
-
* @memberof UnderpostScript
|
|
75
|
-
*/
|
|
76
|
-
get(key) {
|
|
77
|
-
const npmRoot = `${getNpmRootPath()}/underpost`;
|
|
78
|
-
const packageJson = JSON.parse(fs.readFileSync(`${npmRoot}/package.json`, 'utf8'));
|
|
79
|
-
logger.info('[get] ' + key, packageJson.scripts[key]);
|
|
80
|
-
return packageJson.scripts[key];
|
|
81
|
-
},
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export default UnderpostScript;
|
package/src/monitor.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// https://nodejs.org/api
|
|
4
|
-
// https://expressjs.com/en/4x/api.html
|
|
5
|
-
|
|
6
|
-
import dotenv from 'dotenv';
|
|
7
|
-
import { loggerFactory } from './server/logger.js';
|
|
8
|
-
import { ProcessController } from './server/process.js';
|
|
9
|
-
import { getUnderpostRootPath } from './server/conf.js';
|
|
10
|
-
import fs from 'fs-extra';
|
|
11
|
-
import UnderpostMonitor from './cli/monitor.js';
|
|
12
|
-
|
|
13
|
-
const underpostRootPath = getUnderpostRootPath();
|
|
14
|
-
fs.existsSync(`${underpostRootPath}/.env`)
|
|
15
|
-
? dotenv.config({ path: `${underpostRootPath}/.env`, override: true })
|
|
16
|
-
: dotenv.config();
|
|
17
|
-
|
|
18
|
-
const logger = loggerFactory(import.meta);
|
|
19
|
-
|
|
20
|
-
await logger.setUpInfo();
|
|
21
|
-
|
|
22
|
-
const deployId = process.argv[2];
|
|
23
|
-
const env = process.argv[3] || 'production';
|
|
24
|
-
const replicas = process.argv[4] || '1';
|
|
25
|
-
const namespace = process.argv[5] || 'default';
|
|
26
|
-
|
|
27
|
-
UnderpostMonitor.API.callback(deployId, env, {
|
|
28
|
-
type: 'blue-green',
|
|
29
|
-
sync: true,
|
|
30
|
-
replicas,
|
|
31
|
-
namespace,
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
ProcessController.init(logger);
|