live-stream-radio
live-stream-radio copied to clipboard
Graceful error messages
Right now, whenever the stream returns an error it either stays in the current state and waits for a control+c termination or exits out of the loop completely.
I think as this is a live-stream project, the module should gracefully output errors in an optional log file and restart itself on non-crucial errors (ffmpeg errors out, song/video couldn't be loaded)
@AndreasWebdev +1 for a log file, can totally be defined in the config.json
Yeah errors are kind of funny, since We are using node fluent ffmpeg, I noticed it is kinda finnicky.
restart itself on non-crucial errors (ffmpeg errors out, song/video couldn't be loaded)
I actually disagree with that, I think the same could be send for server Applicaitons like express. The expectation is that you use something like forever. In my case, I use systemd to manage my processes, and start them on boot / restart them on crash. I don't think we should be responsible for this, especially since some people may not want it to auto-restart. Please feel free however to make any objections, glad to have a discussion about this 😄
The thing I noticed on my stability test is, that fluent-ffmpeg randomly spills out "this file does not exist" and goes into an uncatched exception state where the process is still alive but not doing anything. From my understanding this should be handled on an application context.
I agree with anything that has nothing to do with the stream itself though (like ffmpeg getting confused, config.json invalid or similar).
I think the problem I encountered was something like [video_overlay] was not defined, I think this happened when a song had an unsafe string as artist/title, so it should fix with #68
Ahhh in the case where the process hangs yes, we should definitely fix that, but I think by exiting. I'm surprised that fluent ffmpeg does not. I may just add a process.exit(1)
and force it to exit then 😄
Thanks for clarifying that! I appreciate it 😄
I've been trying out forever however it does not seem to accept globally installed npm packages, at least it tries to search for it in my home folder. Do you have an example for using systemd? I only know you can create services with it (like in your linked tutorial) however where would I define it to restart after a crash?
Oh yeah! I do! I ended just making a service that logs in as you user, sources your bashrc, and then runs commands. Here's the template I made for it: https://github.com/torch2424/dotFiles/blob/master/.files_templates/systemctl.service
This should fix things for you, and the parts you need to replace are in [] :)
And to answer your question, notice it has "Restart=always". Though if it crashes like 5 times in a row after just barely starting the command, systems will kill it, because 9/10 it means that something's completely wrong, and ususally it is :)