How to isolate a server crash script in PHP?

Oh my God. I never thought that I would need to ask you about this. But unfortunately, yes, I need to!

I have a PHP written script that uses ffmpeg-php. And ffmpeg-php is a bastard. For some input, it works fine, but for some it breaks my entire PHP and the server produces Internal Server Error 500. I tried several times to update ffmpeg-php, ffmpeg, etc., but when for some input it works in version 0, 5 to 0.6 it will not work. And I need to make sure that the rest of the script will be processed correctly. And now this is not so, because when it comes to running toGDImage () in a movie frame, I have Internal Server Error 500 and there is no feedback why from any source.

So, for the peace of my users, I decided that I need to isolate this part of the script, which is messy with ffmpeg-php. I need a way to assure that if something goes horribly wrong in this part, it will continue.

Try catch does not work because it is not a warning and not a fatal error, it is a terrible server disaster. So what are your suggestions?

I am thinking of putting this script in another file called ffmpeg-php-process.php and calling it via HTTP and reading the result, if it is Internal Server Error 500 - I will know that this is not normal.

Or are there any other tidier ways to isolate distress scripts in PHP?

Ps. Do not write that I need to diagnose or debug or find the source of the error. I'm not a damn newbie, and I'm not a ffmpeg developer, to break into this code, I need to make my users safe now, and that’s all I need right now.

+3
source share
3 answers

If you get a 500 error, this is because some kind of exception is thrown to a level lower than that of PHP itself. If your code does not rotate in some infinite loop or does not reach the recursion limit (and even more so since it works with version 0.5), there is a good chance that ffmpeg or ffmpeg-php will fail and use the PHP instance that launched it using it.

Honestly, you cannot do anything with PHP.

, , script, , Python. ffmpeg python, . Python script PHP . , PHP script . ffmpeg-php (, , ).

PHP ( ), PHP script php-cli PHP ( Python). , .

, !

+2

, php-ffmpeg script. : proc_open() .

: http://php.net/proc_open

+2

, , php-email, . , , . , . , ....

, , . ( ). , .

However, it creates a connection problem, as it is now, and does not work on the local computer, and you will talk to another, at least with a small number of wires in one case (I hope)

+1
source

Source: https://habr.com/ru/post/1768515/


All Articles