kourou 0.26.1 → 0.26.2
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/README.md +1 -1
- package/lib/commands/app/doctor.js +5 -14
- package/lib/commands/app/start-services.d.ts +0 -1
- package/lib/commands/app/start-services.js +7 -48
- package/lib/commands/instance/kill.js +2 -1
- package/lib/commands/instance/spawn.d.ts +0 -1
- package/lib/commands/instance/spawn.js +11 -68
- package/lib/support/docker/checkPrerequisites.d.ts +2 -0
- package/lib/support/docker/checkPrerequisites.js +35 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,6 +7,7 @@ const kuzzle_1 = require("../../support/kuzzle");
|
|
|
7
7
|
const elasticsearch_1 = require("@elastic/elasticsearch");
|
|
8
8
|
const execute_1 = require("../../support/execute");
|
|
9
9
|
const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
|
|
10
|
+
const checkPrerequisites_1 = require("../../support/docker/checkPrerequisites");
|
|
10
11
|
class AppDoctor extends common_1.Kommand {
|
|
11
12
|
constructor() {
|
|
12
13
|
super(...arguments);
|
|
@@ -169,21 +170,11 @@ class AppDoctor extends common_1.Kommand {
|
|
|
169
170
|
suggestions.push(`Install missing libraries: sudo apt-get install ${notInstalled.join(" ")}`);
|
|
170
171
|
}
|
|
171
172
|
this.log("Docker checks");
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
if (matches === null || matches.length === 0) {
|
|
176
|
-
this.logKo("Docker Version cannot be found");
|
|
177
|
-
}
|
|
178
|
-
else {
|
|
179
|
-
this.logOk(`Docker Compose Version: ${matches[1]}`);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
catch (error) {
|
|
183
|
-
this.logKo("Docker Compose cannot be found");
|
|
184
|
-
suggestions.push("Install Docker Compose with 'npm run install:docker'");
|
|
173
|
+
const result = await (0, checkPrerequisites_1.checkPrerequisites)(this);
|
|
174
|
+
if (!result) {
|
|
175
|
+
suggestions.push("Install Docker and the Compose plugin");
|
|
185
176
|
}
|
|
186
|
-
this.log(`----------------- DoKtor
|
|
177
|
+
this.log(`----------------- DoKtor finished its job ! -----------------`);
|
|
187
178
|
this.log(`He suggest you to check the following points:`);
|
|
188
179
|
for (const suggestion of suggestions) {
|
|
189
180
|
this.logInfo(" => " + suggestion);
|
|
@@ -5,11 +5,10 @@ const fs_1 = require("fs");
|
|
|
5
5
|
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
6
6
|
const command_1 = require("@oclif/command");
|
|
7
7
|
const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
|
|
8
|
-
const listr_1 = (0, tslib_1.__importDefault)(require("listr"));
|
|
9
8
|
const node_emoji_1 = (0, tslib_1.__importDefault)(require("node-emoji"));
|
|
10
9
|
const common_1 = require("../../common");
|
|
11
10
|
const execute_1 = require("../../support/execute");
|
|
12
|
-
const
|
|
11
|
+
const checkPrerequisites_1 = require("../../support/docker/checkPrerequisites");
|
|
13
12
|
const kuzzleServicesFile = `
|
|
14
13
|
version: '3'
|
|
15
14
|
|
|
@@ -31,7 +30,7 @@ class AppStartServices extends common_1.Kommand {
|
|
|
31
30
|
this.createKourouDir();
|
|
32
31
|
const docoFilename = path_1.default.join(this.kourouDir, "kuzzle-services.yml");
|
|
33
32
|
const successfullCheck = this.flags.check
|
|
34
|
-
? await
|
|
33
|
+
? await (0, checkPrerequisites_1.checkPrerequisites)(this)
|
|
35
34
|
: true;
|
|
36
35
|
if (this.flags.check && successfullCheck) {
|
|
37
36
|
this.log(`\n${node_emoji_1.default.get("ok_hand")} Prerequisites are ${chalk_1.default.green.bold("OK")}!`);
|
|
@@ -39,62 +38,22 @@ class AppStartServices extends common_1.Kommand {
|
|
|
39
38
|
else if (this.flags.check && !successfullCheck) {
|
|
40
39
|
throw new Error(`${node_emoji_1.default.get("shrug")} Your system doesn't satisfy all the prerequisites. Cannot run Kuzzle services.`);
|
|
41
40
|
}
|
|
42
|
-
this.log(chalk_1.default.grey(`\nWriting
|
|
41
|
+
this.log(chalk_1.default.grey(`\nWriting the Docker Compose file to ${docoFilename}...\n`));
|
|
43
42
|
(0, fs_1.writeFileSync)(docoFilename, kuzzleServicesFile);
|
|
44
43
|
// clean up
|
|
45
|
-
await (0, execute_1.execute)("docker
|
|
44
|
+
await (0, execute_1.execute)("docker", "compose", "-f", docoFilename, "down");
|
|
46
45
|
try {
|
|
47
|
-
await (0, execute_1.execute)("docker
|
|
46
|
+
await (0, execute_1.execute)("docker", "compose", "-f", docoFilename, "up", "-d");
|
|
48
47
|
this.logOk("Elasticsearch and Redis are booting in the background right now.");
|
|
49
48
|
this.log(chalk_1.default.grey("\nTo watch the logs, run"));
|
|
50
|
-
this.log(chalk_1.default.blue.bold(` docker
|
|
49
|
+
this.log(chalk_1.default.blue.bold(` docker compose -f ${docoFilename} logs -f\n`));
|
|
51
50
|
this.log(` Elasticsearch port: ${chalk_1.default.bold("9200")}`);
|
|
52
51
|
this.log(` Redis port: ${chalk_1.default.bold("6379")}`);
|
|
53
52
|
}
|
|
54
53
|
catch (error) {
|
|
55
54
|
this.logKo(` Something went wrong: ${error.message}`);
|
|
56
55
|
this.log(chalk_1.default.grey("If you want to investigate the problem, try running"));
|
|
57
|
-
this.log(chalk_1.default.grey(` docker
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
async checkPrerequisites() {
|
|
61
|
-
this.log(chalk_1.default.grey("Checking prerequisites..."));
|
|
62
|
-
const checks = new listr_1.default([
|
|
63
|
-
{
|
|
64
|
-
title: `docker-compose exists and the version is at least ${MIN_DOCO_VERSION}`,
|
|
65
|
-
task: async () => {
|
|
66
|
-
try {
|
|
67
|
-
const docov = await (0, execute_1.execute)("docker-compose", "-v");
|
|
68
|
-
const matches = docov.stdout.match(/[^0-9.]*([0-9.]*).*/);
|
|
69
|
-
if (matches === null) {
|
|
70
|
-
throw new Error("Unable to read docker-compose verson. This is weird.");
|
|
71
|
-
}
|
|
72
|
-
const docoVersion = matches.length > 0 ? matches[1] : null;
|
|
73
|
-
if (docoVersion === null) {
|
|
74
|
-
throw new Error("Unable to read docker-compose version. This is weird.");
|
|
75
|
-
}
|
|
76
|
-
try {
|
|
77
|
-
if (docoVersion < MIN_DOCO_VERSION) {
|
|
78
|
-
throw new Error(`The detected version of docker-compose (${docoVersion}) is not recent enough (${MIN_DOCO_VERSION})`);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
catch (error) {
|
|
82
|
-
throw new Error(error);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
catch (error) {
|
|
86
|
-
throw new Error("No docker-compose found. Are you sure docker-compose is installed?");
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
]);
|
|
91
|
-
try {
|
|
92
|
-
await checks.run();
|
|
93
|
-
return true;
|
|
94
|
-
}
|
|
95
|
-
catch (error) {
|
|
96
|
-
this.logKo(error.message);
|
|
97
|
-
return false;
|
|
56
|
+
this.log(chalk_1.default.grey(` docker compose -f ${docoFilename} up\n`));
|
|
98
57
|
}
|
|
99
58
|
}
|
|
100
59
|
}
|
|
@@ -50,7 +50,8 @@ class InstanceLogs extends common_1.Kommand {
|
|
|
50
50
|
cli_ux_1.default.action.start(`${node_emoji_1.default.get("boom")} Killing Kuzzle instance ${instanceName}`, undefined, {
|
|
51
51
|
stdout: true,
|
|
52
52
|
});
|
|
53
|
-
const instanceKill = (0, child_process_1.spawn)("docker
|
|
53
|
+
const instanceKill = (0, child_process_1.spawn)("docker", [
|
|
54
|
+
"compose",
|
|
54
55
|
"-f",
|
|
55
56
|
docoFilename,
|
|
56
57
|
"-p",
|
|
@@ -8,12 +8,12 @@ const command_1 = require("@oclif/command");
|
|
|
8
8
|
const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
|
|
9
9
|
const child_process_1 = require("child_process");
|
|
10
10
|
const cli_ux_1 = (0, tslib_1.__importDefault)(require("cli-ux"));
|
|
11
|
-
const listr_1 = (0, tslib_1.__importDefault)(require("listr"));
|
|
12
11
|
const node_emoji_1 = (0, tslib_1.__importDefault)(require("node-emoji"));
|
|
13
12
|
const common_1 = require("../../common");
|
|
14
13
|
const execute_1 = require("../../support/execute");
|
|
14
|
+
const checkPrerequisites_1 = require("../../support/docker/checkPrerequisites");
|
|
15
15
|
const MIN_MAX_MAP_COUNT = 262144;
|
|
16
|
-
const MIN_DOCO_VERSION = "
|
|
16
|
+
const MIN_DOCO_VERSION = "2.0.0";
|
|
17
17
|
const kuzzleStackV1 = (increment) => `
|
|
18
18
|
version: '3'
|
|
19
19
|
|
|
@@ -89,7 +89,7 @@ class InstanceSpawn extends common_1.Kommand {
|
|
|
89
89
|
const portIndex = await this.findAvailablePort();
|
|
90
90
|
const docoFilename = path_1.default.join(this.kourouDir, `kuzzle-stack-${portIndex}.yml`);
|
|
91
91
|
const successfullCheck = this.flags.check
|
|
92
|
-
? await
|
|
92
|
+
? await (0, checkPrerequisites_1.checkPrerequisites)(this)
|
|
93
93
|
: true;
|
|
94
94
|
if (this.flags.check && successfullCheck) {
|
|
95
95
|
this.log(`\n${node_emoji_1.default.get("ok_hand")} Prerequisites are ${chalk_1.default.green.bold("OK")}!`);
|
|
@@ -97,11 +97,12 @@ class InstanceSpawn extends common_1.Kommand {
|
|
|
97
97
|
else if (this.flags.check && !successfullCheck) {
|
|
98
98
|
throw new Error(`${node_emoji_1.default.get("shrug")} Your system doesn't satisfy all the prerequisites. Cannot run Kuzzle.`);
|
|
99
99
|
}
|
|
100
|
-
this.log(chalk_1.default.grey(`\nWriting docker
|
|
100
|
+
this.log(chalk_1.default.grey(`\nWriting docker compose file to ${docoFilename}...`));
|
|
101
101
|
(0, fs_1.writeFileSync)(docoFilename, this.generateDocoFile(this.flags.version, portIndex));
|
|
102
102
|
// clean up
|
|
103
|
-
await (0, execute_1.execute)("docker
|
|
104
|
-
const doco = (0, child_process_1.spawn)("docker
|
|
103
|
+
await (0, execute_1.execute)("docker", "compose", "-f", docoFilename, "-p", `stack-${portIndex}`, "down");
|
|
104
|
+
const doco = (0, child_process_1.spawn)("docker", [
|
|
105
|
+
"compose",
|
|
105
106
|
"-f",
|
|
106
107
|
docoFilename,
|
|
107
108
|
"-p",
|
|
@@ -117,78 +118,20 @@ class InstanceSpawn extends common_1.Kommand {
|
|
|
117
118
|
cli_ux_1.default.action.stop("done");
|
|
118
119
|
this.log(`\n${node_emoji_1.default.get("thumbsup")} ${chalk_1.default.bold("Kuzzle is booting")} in the background right now.`);
|
|
119
120
|
this.log(chalk_1.default.grey("To watch the logs, run"));
|
|
120
|
-
this.log(chalk_1.default.grey(` docker
|
|
121
|
+
this.log(chalk_1.default.grey(` docker compose -f ${docoFilename} -p stack-${portIndex} logs -f\n`));
|
|
121
122
|
this.log(` Kuzzle port: ${7512 + portIndex}`);
|
|
122
123
|
this.log(` MQTT port: ${1883 + portIndex}`);
|
|
123
124
|
this.log(` Node.js debugger port: ${9229 + portIndex}`);
|
|
124
125
|
this.log(` Elasticsearch port: ${9200 + portIndex}`);
|
|
125
126
|
}
|
|
126
127
|
else {
|
|
127
|
-
cli_ux_1.default.action.stop(chalk_1.default.red(` Something went wrong: docker
|
|
128
|
+
cli_ux_1.default.action.stop(chalk_1.default.red(` Something went wrong: docker compose exited with ${docoCode}`));
|
|
128
129
|
this.log(chalk_1.default.grey("If you want to investigate the problem, try running"));
|
|
129
|
-
this.log(chalk_1.default.grey(` docker
|
|
130
|
-
throw new Error("docker
|
|
130
|
+
this.log(chalk_1.default.grey(` docker compose -f ${docoFilename} -p stack-${portIndex} up\n`));
|
|
131
|
+
throw new Error("docker compose exited with a non-zero status");
|
|
131
132
|
}
|
|
132
133
|
});
|
|
133
134
|
}
|
|
134
|
-
async checkPrerequisites() {
|
|
135
|
-
this.log(chalk_1.default.grey("Checking prerequisites..."));
|
|
136
|
-
const checks = new listr_1.default([
|
|
137
|
-
{
|
|
138
|
-
title: `docker-compose exists and the version is at least ${MIN_DOCO_VERSION}`,
|
|
139
|
-
task: async () => {
|
|
140
|
-
try {
|
|
141
|
-
const docov = await (0, execute_1.execute)("docker-compose", "-v");
|
|
142
|
-
const matches = docov.stdout.match(/[^0-9.]*([0-9.]*).*/);
|
|
143
|
-
if (matches === null) {
|
|
144
|
-
throw new Error("Unable to read docker-compose verson. This is weird.");
|
|
145
|
-
}
|
|
146
|
-
const docoVersion = matches.length > 0 ? matches[1] : null;
|
|
147
|
-
if (docoVersion === null) {
|
|
148
|
-
throw new Error("Unable to read docker-compose version. This is weird.");
|
|
149
|
-
}
|
|
150
|
-
try {
|
|
151
|
-
if (docoVersion < MIN_DOCO_VERSION) {
|
|
152
|
-
throw new Error(`The detected version of docker-compose (${docoVersion}) is not recent enough (${MIN_DOCO_VERSION})`);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
catch (error) {
|
|
156
|
-
throw new Error(error);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
catch (error) {
|
|
160
|
-
throw new Error("No docker-compose found. Are you sure docker-compose is installed?");
|
|
161
|
-
}
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
title: `vm.max_map_count is greater than ${MIN_MAX_MAP_COUNT}`,
|
|
166
|
-
task: async () => {
|
|
167
|
-
try {
|
|
168
|
-
const sysctl = await (0, execute_1.execute)("/sbin/sysctl", "-n", "vm.max_map_count");
|
|
169
|
-
if (sysctl.exitCode !== 0) {
|
|
170
|
-
throw new Error("Something went wrong checking vm.max_map_count");
|
|
171
|
-
}
|
|
172
|
-
const value = parseInt(sysctl.stdout, 10);
|
|
173
|
-
if (value < MIN_MAX_MAP_COUNT) {
|
|
174
|
-
throw new Error(`vm.max_map_count must be at least ${MIN_MAX_MAP_COUNT} (found ${value})`);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
catch (error) {
|
|
178
|
-
throw new Error(`Something went wrong checking vm.max_map_count: ${error.message}`);
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
},
|
|
182
|
-
]);
|
|
183
|
-
try {
|
|
184
|
-
await checks.run();
|
|
185
|
-
return true;
|
|
186
|
-
}
|
|
187
|
-
catch (error) {
|
|
188
|
-
this.logKo(error.message);
|
|
189
|
-
return false;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
135
|
generateDocoFile(kuzzleMajor, portIndex) {
|
|
193
136
|
if (kuzzleMajor === "1") {
|
|
194
137
|
return kuzzleStackV1(portIndex);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkPrerequisites = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const listr_1 = (0, tslib_1.__importDefault)(require("listr"));
|
|
6
|
+
const execute_1 = require("../execute");
|
|
7
|
+
const MIN_DOCO_VERSION = "2.0.0";
|
|
8
|
+
async function checkPrerequisites(ctx) {
|
|
9
|
+
const checks = new listr_1.default([
|
|
10
|
+
{
|
|
11
|
+
title: `docker compose exists and the version is at least ${MIN_DOCO_VERSION}`,
|
|
12
|
+
task: async () => {
|
|
13
|
+
const docov = await (0, execute_1.execute)("docker", "compose", "version");
|
|
14
|
+
const matches = docov.stdout.match(/[^0-9.]*([0-9.]*).*/);
|
|
15
|
+
const docoVersion = matches ? matches[1] : null;
|
|
16
|
+
ctx.logInfo(`Found Docker Compose version: ${docoVersion}`);
|
|
17
|
+
if (!docoVersion) {
|
|
18
|
+
throw new Error("Unable to read the version of Docker Compose. Are you sure Docker and the Compose plugin are installed?");
|
|
19
|
+
}
|
|
20
|
+
if (docoVersion < MIN_DOCO_VERSION) {
|
|
21
|
+
throw new Error(`Your version of Docker Compose (${docoVersion}) is below the required version (${MIN_DOCO_VERSION}).`);
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
]);
|
|
26
|
+
try {
|
|
27
|
+
await checks.run();
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
ctx.logKo(error.message);
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.checkPrerequisites = checkPrerequisites;
|