Running background processes - accessing same script twice

I have a PHP script that aims to integrate with a third-party system.

Basically, my script sends image and text files to the client ftp.

To ensure processing for a long time, I use the following statement:

ignore_user_abort( true ); // Não interrompe o script em caso de perda de conexão
set_time_limit( 21600 ); // Time out após 6h

Also, to prevent double processing, a file is created at the beginning, which, at the end of the script, is deleted.

So that if the file exists, it is because the process is in execution.

The script works beautifully.

The problem lies in the fact that this script is called via AJAX by my system (asynchronously), then being run in the background. But then, once the process has started, I can not do anything else on the system while it does not end, unless I open in another browser or using another protocol(one with www and another without).

Is this browser limitation, or is it something that can be configured in the server / php?

Thank you for your help!

Obs.: there are several processes running in the background on the system, but this is the only one that crashes the other processes.

Author: Szag-Ot, 2014-08-15

1 answers

Ok guys, thank you for the time you gave me helping (especially @ Sergio), but I found the solution.

The problem is in a simple error. I've done it before, but it's been a while... I ended up remembering and actually found it to be the following:

I open a session at the beginning of the process (with session_start(), of course) but do not close it at any time (with session_write_close()).

This is not about closing or destroying the session. It's just a matter of getting informed for the script you no longer need it after certain point.

Once placed session_write_close() right after the line to make use of the session for the last time, the problem no longer occurs.

Thanks again!

 3
Author: Szag-Ot, 2014-08-15 20:49:51