I am trying to start Unity instance in batch mode with -executeMethod to build asset bundles of more than 2000 textures using a command like this:
"C:\Program Files\Unity\Hub\Editor\2020.3.1f1\Editor\Unity.exe" -batchmode -projectPath "D:\UnityWorkbench\2020\Build Texture Asset Bundle" -executeMethod DummyNamespace.TexturesManager.BuildTextureAssetBundles -env TEST
Now, I want to create a REST API using PHP to execute this command on a AWS EC2 windows server. I used the below script to start the instance and execute the static method in the unity project.
<?php
$commandStr = '"C:\Program Files\Unity\Hub\Editor\2020.3.1f1\Editor\Unity.exe" -batchmode -projectPath "D:\UnityWorkbench\2020\Build Texture Asset Bundle" -executeMethod DummyNamespace.TexturesManager.BuildTextureAssetBundles -env TEST';
$output=null;
$retval=null;
exec($commandStr, $output, $retval);
echo "retval: ".$retval."\n\n";
echo "output: ".$output."\n\n";
?>
This script starts the unity instance and then waits for its execution to return the response. Hence, it always reaches PHP request timeout as it builds more than 2000 images in the asset bundle, which could take some time to complete.
How do I make it start the instance in batch mode in the background and immediately return a response of whether it started or not?
P.S. - I tried pclose(popen($commandStr, 'r')); but that doesn't start the unity instance at all. Please help!