Init Repo

This commit is contained in:
root
2019-09-06 23:53:10 +08:00
commit f0ef89dfbb
7905 changed files with 914138 additions and 0 deletions

View File

@ -0,0 +1,43 @@
<?php
declare(ticks = 1);
Swoole\Async::set([
'enable_signalfd' => false,
]);
class FunctionTimeoutException extends RuntimeException
{
}
function test()
{
sleep(1);
}
$serv = new Swoole\Http\Server("127.0.0.1", 9502);
$serv->set(['worker_num' => 1]);
$serv->on('WorkerStart', function($serv, $workerId) {
pcntl_signal(SIGALRM, function () {
Swoole\Process::alarm(-1);
throw new FunctionTimeoutException;
});
});
$serv->on('Request', function($request, $response) {
try
{
Swoole\Process::alarm(100 * 1000);
test();
Swoole\Process::alarm(-1);
$response->end("<h1>Finish</h1>");
}
catch(FunctionTimeoutException $e)
{
$response->end("<h1>Timeout</h1>");
}
});
$serv->start();