@certik/skynet 0.10.26 → 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 +8 -0
- package/api.js +24 -5
- package/app.d.ts +1 -0
- package/app.js +1 -0
- package/deploy.js +14 -2
- 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
|
|
@@ -108,7 +120,6 @@ const genConfig = ({
|
|
|
108
120
|
|
|
109
121
|
env {
|
|
110
122
|
SKYNET_ENVIRONMENT="${isProduction ? "prd" : "dev"}"
|
|
111
|
-
AWS_REGION="${region}"
|
|
112
123
|
}
|
|
113
124
|
|
|
114
125
|
kill_timeout = "120s"
|
|
@@ -171,7 +182,6 @@ EOH
|
|
|
171
182
|
# available to the task when it runs.
|
|
172
183
|
env {
|
|
173
184
|
SKYNET_ENVIRONMENT="${isProduction ? "prd" : "dev"}"
|
|
174
|
-
AWS_REGION="${region}"
|
|
175
185
|
}
|
|
176
186
|
|
|
177
187
|
# Specify the maximum resources required to run the task,
|
|
@@ -514,6 +524,7 @@ function createDeploy({
|
|
|
514
524
|
selector = {},
|
|
515
525
|
region = "us-east-1",
|
|
516
526
|
env = {},
|
|
527
|
+
count,
|
|
517
528
|
check,
|
|
518
529
|
schedule,
|
|
519
530
|
restart,
|
|
@@ -544,6 +555,7 @@ function createDeploy({
|
|
|
544
555
|
const nomadJobDefinition = genConfig({
|
|
545
556
|
jobName,
|
|
546
557
|
cron: INTERVAL_ALIASES[cron] || cron,
|
|
558
|
+
count,
|
|
547
559
|
restart,
|
|
548
560
|
workingDirectory,
|
|
549
561
|
additionalEnv: env,
|