-
Notifications
You must be signed in to change notification settings - Fork 0
/
runDockerFunction.js
38 lines (34 loc) · 1.02 KB
/
runDockerFunction.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const request = require('request')
const payloadFileName = './payloads/payload.json'
run = () => {
let payload = {
"value": require((process.argv[2] || payloadFileName))
}
request({
url: "http://localhost:8080/init",
method: "POST",
json: true,
body: payload
}, function (error, response, body) {
if (!error && response.statusCode === 200) {
console.log("/init has been successful")
request({
url: "http://localhost:8080/run",
method: "POST",
json: true,
body: payload
}, function (error, response, body) {
if (!error && response.statusCode === 200) {
console.log(JSON.stringify(body, null, 3))
}
else {
console.log("Error invoking /run: " + error)
}
})
}
else {
console.log("Error invoking /init: " + error)
}
})
}
run()