如果您期望大量流量,您应该认真考虑专用服务器.
在单个服务器上,您可以使用shell_exec和UNIX nohup命令来获取进程的PID.
function run_in_background($Command, $Priority = 0)
{
if($Priority)
$PID = shell_exec("nohup nice -n $Priority $Command 2> /dev/null & echo $!");
else
$PID = shell_exec("nohup $Command 2> /dev/null & echo $!");
return($PID);
}
function is_process_running($PID)
{
exec("ps $PID", $ProcessState);
return(count($ProcessState) >= 2);
}
您可以将PID列表放在MySQL表中,然后每5分钟使用一次cron作业来检测视频何时完成并更新数据库中的相关值.