Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runOnDemand command doesn't stop the processes executed from the win10 batch #3004

Closed
1 of 13 tasks
rktr2009 opened this issue Feb 10, 2024 · 8 comments · Fixed by #3087
Closed
1 of 13 tasks

runOnDemand command doesn't stop the processes executed from the win10 batch #3004

rktr2009 opened this issue Feb 10, 2024 · 8 comments · Fixed by #3087
Labels
enhancement New feature or request general

Comments

@rktr2009
Copy link

rktr2009 commented Feb 10, 2024

Which version are you using?

v1.5.1

Which operating system are you using?

  • Linux amd64 standard
  • Linux amd64 Docker
  • Linux arm64 standard
  • Linux arm64 Docker
  • Linux arm7 standard
  • Linux arm7 Docker
  • Linux arm6 standard
  • Linux arm6 Docker
  • Windows amd64 standard
  • Windows amd64 Docker (WSL backend)
  • macOS amd64 standard
  • macOS amd64 Docker
  • Other (please describe)

Describe the issue

A batch file , which consist of a streamlink -> ffmpeg pipe as source to mediamtx, is successfully called at runOnDemand, but doesn't close the processes after the time of runOnDemandCloseAfter.

Setup is,

paths:
  stream1:
    runOnDemand: cmd /k "C:\Users\Applications\batch\stream1.bat"
    runOnDemandStartTimeout: 30s
    runOnDemandCloseAfter: 30s

Inside of stream1.bat is like,

streamlink https://www.youtube.com/watch?v=VNaaaaaaaa 360p -O | ffmpeg -re -i - -vcodec copy -acodec libmp3lame -r 5 -f rtsp rtsp://192.168.111.111:8554/

Describe how to replicate the issue

Happens everytime I access the stream from the client.
If mediamtx is terminated, the processes will terminate too.
It used to work before but started to fail to terminate the processes I think from the last version of rtsp-simple-server or around that.

Did you attach the server logs?

I see in the log,
runOnDemand command stopped: not needed by anyone,
but doesn't terminate the child processes.

Did you attach a network dump?

no

@DigitalRogues
Copy link

I ran into this also with linux and having a bash script as the runondemand command, but once I moved all the code out of the script into the yaml directly it worked.

it would be nice to have the bash script get terminated as well.

@davidtaddei
Copy link

I've also found this happening in Linux. The best workaround I have is to make the bash script have a start and stop command. I then call the script with start with runOnDemand and call it again with stop on runOnUndemand and kill the appropriate processes. I'd recommend logging specific PIDs to a file in the case of multiple instances.

@rktr2009
Copy link
Author

I ran into this also with linux and having a bash script as the runondemand command, but once I moved all the code out of the script into the yaml directly it worked.

it would be nice to have the bash script get terminated as well.

Great that worked for you, bringing the script into yaml :) I tried that before in windows, but somehow couldn't convert the script into yaml which gave me errors. The pipe part(updated above) didn't work I guess.

@aler9
Copy link
Member

aler9 commented Feb 29, 2024

Hello, after replicating the issue on both Linux and Windows, it turned out that MediaMTX does indeed send the kill signal to the process written inside runOnDemand, but not to its subprocesses, if there are any, causing them to remain active.

In case of commands wrapped inside shell scripts like cmd /k "C:\Users\Applications\batch\stream1.bat", the main process is cmd.exe and not streamlink.exe or ffmpeg.exe.

In order to ease the integration with third-party software, i wrote a patch that propagates the kill signal to subprocesses too, and this should solve the issue on all supported operating systems.

Contrarily to what reported in this thread, closing subprocesses was never a feature of rtsp-simple-server.

@rktr2009
Copy link
Author

rktr2009 commented Mar 2, 2024

Thank you for your support of coming out with a fix. I will test it once after the next release comes out.

Copy link
Contributor

github-actions bot commented Mar 4, 2024

This issue is mentioned in release v1.6.0 🚀
Check out the entire changelog by clicking here

@rktr2009
Copy link
Author

rktr2009 commented Mar 6, 2024

After testing, I am not really sure if runOnDemandCloseAfter is kicking in exactly after 30s, as per my config, but I can see the processes are closing around that timeframe, thanks!

Copy link
Contributor

github-actions bot commented Sep 9, 2024

This issue is being locked automatically because it has been closed for more than 6 months.
Please open a new issue in case you encounter a similar problem.

@github-actions github-actions bot locked and limited conversation to collaborators Sep 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request general
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants