Skip to content

Commit 810fd1c

Browse files
committed
FFMPEG now check status on LB
1 parent a053109 commit 810fd1c

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

Diff for: app.js

+17-6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,20 @@ const env = process.env;
1010
// Get args
1111
const arg = process.argv.slice(2);
1212

13+
let id = false;
14+
15+
const checkStatus = () => {
16+
if (!id)
17+
return;
18+
fetch(`${config.URL}api/ffmpeg/${id}`).then(res => (res.json())).then((data) => {
19+
if (typeof(data.status) !== 'undefined' && data.status !== false) {
20+
process.exit(parseInt(data.status));
21+
}
22+
}).catch((err) => {
23+
console.error(err);
24+
});
25+
}
26+
1327
// Call the load-balancer
1428
fetch(`${config.URL}api/ffmpeg`, {
1529
method: 'POST',
@@ -21,12 +35,9 @@ fetch(`${config.URL}api/ffmpeg`, {
2135
arg,
2236
env
2337
})
38+
}).then(res => (res.json())).then((data) => {
39+
id = data.id;
40+
setInterval(() => {checkStatus(); }, 10000);
2441
}).catch((err) => {
2542
console.error(err);
2643
});
27-
28-
/**
29-
* We need to keep alive the process otherwise
30-
* plex send a bad mpd file
31-
**/
32-
setInterval(() => {}, 3600000);

0 commit comments

Comments
 (0)