@certik/skynet 0.10.28 → 0.10.29
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 +4 -0
- package/api.js +24 -5
- package/app.d.ts +1 -0
- package/app.js +1 -0
- package/deploy.js +14 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
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.count || serve.count === 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
package/deploy.js
CHANGED
|
@@ -46,6 +46,7 @@ const genConfig = ({
|
|
|
46
46
|
workingDirectory,
|
|
47
47
|
cmd,
|
|
48
48
|
cron,
|
|
49
|
+
count,
|
|
49
50
|
restart,
|
|
50
51
|
cpu,
|
|
51
52
|
mem,
|
|
@@ -79,6 +80,17 @@ const genConfig = ({
|
|
|
79
80
|
}
|
|
80
81
|
|
|
81
82
|
group "default" {
|
|
83
|
+
${count && count > 1 ? `count = ${count}` : ""}
|
|
84
|
+
${
|
|
85
|
+
count && count > 1
|
|
86
|
+
? `# Rolling Update
|
|
87
|
+
update {
|
|
88
|
+
max_parallel = 1
|
|
89
|
+
min_healthy_time = "10s"
|
|
90
|
+
}`
|
|
91
|
+
: ""
|
|
92
|
+
}
|
|
93
|
+
|
|
82
94
|
reschedule {
|
|
83
95
|
attempts = 0
|
|
84
96
|
unlimited = false
|
|
@@ -512,6 +524,7 @@ function createDeploy({
|
|
|
512
524
|
selector = {},
|
|
513
525
|
region = "us-east-1",
|
|
514
526
|
env = {},
|
|
527
|
+
count,
|
|
515
528
|
check,
|
|
516
529
|
schedule,
|
|
517
530
|
restart,
|
|
@@ -542,6 +555,7 @@ function createDeploy({
|
|
|
542
555
|
const nomadJobDefinition = genConfig({
|
|
543
556
|
jobName,
|
|
544
557
|
cron: INTERVAL_ALIASES[cron] || cron,
|
|
558
|
+
count,
|
|
545
559
|
restart,
|
|
546
560
|
workingDirectory,
|
|
547
561
|
additionalEnv: env,
|