File tree 1 file changed +17
-6
lines changed
1 file changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,20 @@ const env = process.env;
10
10
// Get args
11
11
const arg = process . argv . slice ( 2 ) ;
12
12
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
+
13
27
// Call the load-balancer
14
28
fetch ( `${ config . URL } api/ffmpeg` , {
15
29
method : 'POST' ,
@@ -21,12 +35,9 @@ fetch(`${config.URL}api/ffmpeg`, {
21
35
arg,
22
36
env
23
37
} )
38
+ } ) . then ( res => ( res . json ( ) ) ) . then ( ( data ) => {
39
+ id = data . id ;
40
+ setInterval ( ( ) => { checkStatus ( ) ; } , 10000 ) ;
24
41
} ) . catch ( ( err ) => {
25
42
console . error ( err ) ;
26
43
} ) ;
27
-
28
- /**
29
- * We need to keep alive the process otherwise
30
- * plex send a bad mpd file
31
- **/
32
- setInterval ( ( ) => { } , 3600000 ) ;
You can’t perform that action at this time.
0 commit comments