Executing a long script

Good day to all!

Please tell me!
I searched the whole Internet, I didn’t find an answer.

When executing long scripts, the whole site hangs, waits for the script to finish, after which you can use the site.

it’s not even about the script, I
made an empty action, with sticking for 40 seconds:

public function actionFork()

when accessing this page of the site, the
script is run, and the “fork” page waits 40 seconds,

why can’t I use the site at the moment? other pages of the site? the
whole site is just waiting for the completion of this script.

at the same time, if I am in the root of the directory, I create a directory “dir”, and in this folder in .htaccess I specify that this folder, as if it had nothing to do with the engine, so that you can access its contents.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php

I create two files:
" index.php " (docs_site/dir/index.php )


and " start.php " (docs_site/dir/start.php )

echo '!@';

then I can use these pages in parallel until " index.php " waiting for 40 seconds. when accessing it…
I open start.php
And I see ‘!@’

why when using Yii2
I am referring to the page docs_site/task/fork :

public function actionFork()

I can’t open any of the pages of this site, the
whole site is just waiting for the script to run.

as if it does not give the opportunity to work with the site in parallel with the execution of this script

Good day Vlad.

Best way to execute long scripts that I know is creating a iterative console script and run it via cronjob.

By iterative I mean that each step you advance in the script you’ll need some sort of save point, were you can stop and continue afterwards if necessary.

You had already asked (and I answered) the question in execution of the debt script.

This does NOT happen when the site is configured for production. This is likely due to the serialization of debug logs.