Skip to content

Commit

Permalink
修复 Windows workerman-gateway 有时候测试失败 (#639)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yurunsoft authored Nov 9, 2023
1 parent 8936a21 commit 47bf0a6
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 12 deletions.
29 changes: 29 additions & 0 deletions .github/print-logs.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,35 @@
{
echo 'Not found!', \PHP_EOL;
}
foreach ([
'websocket',
'register',
'gateway',
'http',
] as $serviceName)
{
$fileName = \dirname(__DIR__) . '/src/Components/workerman-gateway/tests/unit/AppServer/logs/' . $serviceName . '.log';
echo 'File: ', $fileName, \PHP_EOL;
if (is_file($fileName))
{
echo file_get_contents($fileName), \PHP_EOL;
}
else
{
echo 'Not found!', \PHP_EOL;
}

$fileName = \dirname(__DIR__) . '/src/Components/workerman-gateway/tests/unit/AppServer/logs/' . $serviceName . '.error.log';
echo 'File: ', $fileName, \PHP_EOL;
if (is_file($fileName))
{
echo file_get_contents($fileName), \PHP_EOL;
}
else
{
echo 'Not found!', \PHP_EOL;
}
}

echo '[RoadRunner]', \PHP_EOL;
$fileName = \dirname(__DIR__) . '/src/Components/roadrunner/tests/unit/HttpServer/logs/cli.log';
Expand Down
9 changes: 5 additions & 4 deletions src/Components/workerman-gateway/tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,19 +177,20 @@ function runTestServer(string $name, array $options): void
{
$checkStatuses = [$options['checkStatus']];
}
foreach ($checkStatuses as $checkStatus)
foreach ($checkStatuses as $i => $checkStatus)
{
if ($checkStatus())
{
echo "{$name} started!", \PHP_EOL;

return;
var_export($checkStatus);
echo ' OK', \PHP_EOL;
unset($checkStatuses[$i]);
}
else
{
throw new \RuntimeException("{$name} start failed");
}
}
echo "{$name} started!", \PHP_EOL;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$__DIR__ = $(Split-Path -Parent $MyInvocation.MyCommand.Definition)

$server = $args[0]

$procss = Start-Process -PassThru -FilePath "php" -ArgumentList "$__DIR__\workerman workerman/start --name $server" -RedirectStandardOutput "$__DIR__\..\logs\$server.log" -RedirectStandardError "$__DIR__\..\logs\$server.error.log"
$procss.Id | Out-File $__DIR__/$server.pid
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@ $__DIR__ = $(Split-Path -Parent $MyInvocation.MyCommand.Definition)

& $__DIR__\stop-workerman.ps1

$procss = Start-Process -PassThru -FilePath "php" -ArgumentList "$__DIR__\workerman workerman/start --name websocket"
$procss.Id | Out-File $__DIR__/websocket.pid
$procss = Start-Process -PassThru -FilePath "powershell" -ArgumentList "$__DIR__\start-server.ps1 websocket"

$procss = Start-Process -PassThru -FilePath "php" -ArgumentList "$__DIR__\workerman workerman/start --name register"
$procss.Id | Out-File $__DIR__/register.pid
$procss = Start-Process -PassThru -FilePath "powershell" -ArgumentList "$__DIR__\start-server.ps1 register"

$procss = Start-Process -PassThru -FilePath "php" -ArgumentList "$__DIR__\workerman workerman/start --name gateway"
$procss.Id | Out-File $__DIR__/gateway.pid
$procss = Start-Process -PassThru -FilePath "powershell" -ArgumentList "$__DIR__\start-server.ps1 gateway"

$procss = Start-Process -PassThru -FilePath "php" -ArgumentList "$__DIR__\workerman workerman/start --name http"
$procss.Id | Out-File $__DIR__/http.pid
$procss = Start-Process -PassThru -FilePath "powershell" -ArgumentList "$__DIR__\start-server.ps1 http"

0 comments on commit 47bf0a6

Please sign in to comment.