in src/TestUtils/CloudSqlProxyTrait.php [33:61]
public static function startCloudSqlProxy($connectionName, $socketDir, $port = null)
{
// create the directory to store the unix socket for cloud_sql_proxy
if (!is_dir($socketDir) && !@mkdir($socketDir, 0755, true)) {
throw new Exception('Unable to create socket dir ' . $socketDir);
}
$instances = sprintf('-instances=%s', $connectionName);
if ($port) {
$instances = sprintf('%s=tcp:%s,%s', $instances, $port, $connectionName);
}
$process = new Process(['cloud_sql_proxy', $instances, '-dir', $socketDir]);
$process->start();
$process->waitUntil(function ($type, $buffer) {
print($buffer);
return str_contains($buffer, 'Ready for new connections');
});
if (!$process->isRunning()) {
if ($output = $process->getOutput()) {
print($output);
}
if ($errorOutput = $process->getErrorOutput()) {
print($errorOutput);
}
throw new Exception('Failed to start cloud_sql_proxy');
}
return self::$cloudSqlProxyProcess = $process;
}