Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to make a queue in php with mysql

hy,

in my script i run a exec() function to make a movie file with ffmpeg.

the problem is ffmpeg can run only 1 time on the server,

if 2 people are online on server and first one already run ffmpeg i want the second to wait until the first end the process

how to code this?

thank you

like image 513
robert Avatar asked Jan 19 '26 10:01

robert


1 Answers

Set a lock somewhere.

When ffmpeg starts, set a flag in a file or a database table to mark it as in progress. Every time ffmpeg starts, have it check if the flag value is '1', and if so, wait and retry in 5 or 10 seconds. Then when the process ends, set the flag to '0'. Make sure if it crashes or your script has an error that the flag is set back to '0'.

Or, you could likely run the ffmpeg process as a different user, and have more than one running at once.

like image 149
JAL Avatar answered Jan 22 '26 00:01

JAL



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!