1
1
const { CronJob} = require ( 'cron' ) ;
2
- const { cronTime} = require ( '../../mainroom.config' ) ;
2
+ const { cronTime, streamSchedulerTimeout } = require ( '../../mainroom.config' ) ;
3
3
const { ScheduledStream, User, EventStage} = require ( '../model/schemas' ) ;
4
4
const CompositeError = require ( '../errors/CompositeError' ) ;
5
5
const snsErrorPublisher = require ( '../aws/snsErrorPublisher' ) ;
@@ -15,7 +15,7 @@ const jobName = 'Stream Scheduler';
15
15
let lastTimeTriggered = Date . now ( ) ;
16
16
let isFirstTimeTriggered = true ;
17
17
18
- const job = new CronJob ( cronTime . scheduledStreamInfoUpdater , async ( ) => {
18
+ const job = new CronJob ( cronTime . streamScheduler , async ( ) => {
19
19
LOGGER . debug ( `${ jobName } triggered` ) ;
20
20
21
21
const thisTimeTriggered = job . lastDate ( ) . valueOf ( ) ;
@@ -146,9 +146,12 @@ function startStreamFromPrerecordedVideo({startTime, inputURL, streamKey}) {
146
146
`${ RTMP_SERVER_URL } /${ streamKey } ` ) ;
147
147
148
148
mainroomEventBus . once ( `streamStarted_${ streamKey } ` , resolve ) ;
149
+
149
150
spawn ( process . env . FFMPEG_PATH , args , { detached : true , stdio : 'ignore' } )
150
151
. on ( 'error' , reject )
151
152
. unref ( ) ;
153
+
154
+ setTimeout ( reject , streamSchedulerTimeout ) ;
152
155
} ) ;
153
156
}
154
157
@@ -171,7 +174,9 @@ async function startAllStreams(startStreamPromises) {
171
174
}
172
175
}
173
176
174
- LOGGER . info ( 'Successfully started {} out of {} streams from prerecorded videos' , successCount , startStreamPromises . length ) ;
177
+ LOGGER . info ( 'Successfully started {} out of {} streams from prerecorded videos' ,
178
+ successCount , startStreamPromises . length ) ;
179
+
175
180
if ( errors . length ) {
176
181
throw new CompositeError ( errors ) ;
177
182
}
0 commit comments