@certik/skynet 0.10.28 → 0.10.31
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/CHANGELOG.md +12 -0
- package/api.js +24 -5
- package/app.d.ts +1 -0
- package/app.js +8 -1
- package/deploy.d.ts +2 -0
- package/deploy.js +18 -1
- package/examples/api +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.10.31
|
|
4
|
+
|
|
5
|
+
- `api` app bug fix
|
|
6
|
+
|
|
7
|
+
## 0.10.30
|
|
8
|
+
|
|
9
|
+
- Changed `api` app deployment to service type for rolling updates
|
|
10
|
+
|
|
11
|
+
## 0.10.29
|
|
12
|
+
|
|
13
|
+
- Added `serve.instances` parameter to `api` library to support multiple instances
|
|
14
|
+
|
|
3
15
|
## 0.10.28
|
|
4
16
|
|
|
5
17
|
- Fixed `deploy` library aws region bug
|
package/api.js
CHANGED
|
@@ -46,12 +46,29 @@ const apiKeyMiddleware = (key) => {
|
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
// key can be either a string or a map with multiple keys
|
|
50
|
+
if (typeof key === "string") {
|
|
51
|
+
if (apiKey !== key) {
|
|
52
|
+
inline.log("request has an invalid api key");
|
|
51
53
|
|
|
52
|
-
|
|
54
|
+
res.status(400).send("invalid api key");
|
|
53
55
|
|
|
54
|
-
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
inline.log(`requested by valid key ${key.slice(0, 6)}`);
|
|
60
|
+
} else {
|
|
61
|
+
const name = key[apiKey];
|
|
62
|
+
|
|
63
|
+
if (!name) {
|
|
64
|
+
inline.log("request has an invalid api key");
|
|
65
|
+
|
|
66
|
+
res.status(400).send("invalid api key");
|
|
67
|
+
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
inline.log(`requested by authorized user ${name}`);
|
|
55
72
|
}
|
|
56
73
|
|
|
57
74
|
next();
|
|
@@ -93,7 +110,9 @@ ${getSelectorDesc(selector)}
|
|
|
93
110
|
|
|
94
111
|
const { verbose, ...selectorFlags } = cli.flags;
|
|
95
112
|
|
|
96
|
-
|
|
113
|
+
if (!serve.instances || serve.instances === 1) {
|
|
114
|
+
await useLock({ name: getJobName(name, selectorFlags), ttl: 50, verbose });
|
|
115
|
+
}
|
|
97
116
|
|
|
98
117
|
// for health check
|
|
99
118
|
app.get("/", (req, res) => {
|
package/app.d.ts
CHANGED
package/app.js
CHANGED
|
@@ -655,7 +655,14 @@ function api({ name, routes, serve, beforeListen, env = {}, region = "us-east-1"
|
|
|
655
655
|
selector,
|
|
656
656
|
region,
|
|
657
657
|
env,
|
|
658
|
-
|
|
658
|
+
type: "service",
|
|
659
|
+
restart: {
|
|
660
|
+
attempts: 3,
|
|
661
|
+
delay: "15s",
|
|
662
|
+
mode: "fail",
|
|
663
|
+
interval: "30m",
|
|
664
|
+
},
|
|
665
|
+
count: serve.instances,
|
|
659
666
|
cpu: serve.cpu,
|
|
660
667
|
mem: serve.mem,
|
|
661
668
|
service: {
|
package/deploy.d.ts
CHANGED
package/deploy.js
CHANGED
|
@@ -46,17 +46,19 @@ const genConfig = ({
|
|
|
46
46
|
workingDirectory,
|
|
47
47
|
cmd,
|
|
48
48
|
cron,
|
|
49
|
+
count,
|
|
49
50
|
restart,
|
|
50
51
|
cpu,
|
|
51
52
|
mem,
|
|
52
53
|
service,
|
|
53
54
|
additionalEnv = [],
|
|
55
|
+
type = "batch",
|
|
54
56
|
region = "us-east-1",
|
|
55
57
|
isProduction,
|
|
56
58
|
}) => `job "${jobName}" {
|
|
57
59
|
datacenters = ["${region}"]
|
|
58
60
|
|
|
59
|
-
type = "
|
|
61
|
+
type = "${type}"
|
|
60
62
|
|
|
61
63
|
${
|
|
62
64
|
cron
|
|
@@ -79,6 +81,17 @@ const genConfig = ({
|
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
group "default" {
|
|
84
|
+
${count && count > 1 ? `count = ${count}` : ""}
|
|
85
|
+
${
|
|
86
|
+
count && count > 1
|
|
87
|
+
? `# Rolling Update
|
|
88
|
+
update {
|
|
89
|
+
max_parallel = 1
|
|
90
|
+
min_healthy_time = "10s"
|
|
91
|
+
}`
|
|
92
|
+
: ""
|
|
93
|
+
}
|
|
94
|
+
|
|
82
95
|
reschedule {
|
|
83
96
|
attempts = 0
|
|
84
97
|
unlimited = false
|
|
@@ -511,7 +524,9 @@ function createDeploy({
|
|
|
511
524
|
bin = "bin/indexer",
|
|
512
525
|
selector = {},
|
|
513
526
|
region = "us-east-1",
|
|
527
|
+
type = "batch",
|
|
514
528
|
env = {},
|
|
529
|
+
count,
|
|
515
530
|
check,
|
|
516
531
|
schedule,
|
|
517
532
|
restart,
|
|
@@ -542,10 +557,12 @@ function createDeploy({
|
|
|
542
557
|
const nomadJobDefinition = genConfig({
|
|
543
558
|
jobName,
|
|
544
559
|
cron: INTERVAL_ALIASES[cron] || cron,
|
|
560
|
+
count,
|
|
545
561
|
restart,
|
|
546
562
|
workingDirectory,
|
|
547
563
|
additionalEnv: env,
|
|
548
564
|
region,
|
|
565
|
+
type,
|
|
549
566
|
cmd: `${bin} ${args}`,
|
|
550
567
|
cpu,
|
|
551
568
|
mem,
|
package/examples/api
CHANGED