Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4ab6332176 | |||
| abe2dad521 | |||
| b0f70a13da | |||
| 1e8aca91dd | |||
| b4ac5c4758 | |||
| d161477957 |
+23
-2
@@ -3,8 +3,6 @@
|
|||||||
defined('APP_PATH') or define('APP_PATH', realpath(__DIR__ . '/../../'));
|
defined('APP_PATH') or define('APP_PATH', realpath(__DIR__ . '/../../'));
|
||||||
|
|
||||||
|
|
||||||
use Note\Note;
|
|
||||||
use Note\Route\Route;
|
|
||||||
use Http\Handler\Router;
|
use Http\Handler\Router;
|
||||||
use JetBrains\PhpStorm\Pure;
|
use JetBrains\PhpStorm\Pure;
|
||||||
use Kiri\Abstracts\Config;
|
use Kiri\Abstracts\Config;
|
||||||
@@ -16,6 +14,8 @@ use Kiri\Events\EventDispatch;
|
|||||||
use Kiri\Events\EventProvider;
|
use Kiri\Events\EventProvider;
|
||||||
use Kiri\Exception\ConfigException;
|
use Kiri\Exception\ConfigException;
|
||||||
use Kiri\Kiri;
|
use Kiri\Kiri;
|
||||||
|
use Note\Note;
|
||||||
|
use Note\Route\Route;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Swoole\Process;
|
use Swoole\Process;
|
||||||
use Swoole\WebSocket\Server;
|
use Swoole\WebSocket\Server;
|
||||||
@@ -900,6 +900,27 @@ if (!function_exists('di')) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!function_exists('interval')) {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param callable $callback
|
||||||
|
* @param int $interval
|
||||||
|
* @param bool $is
|
||||||
|
*/
|
||||||
|
function interval(callable $callback, int $interval = 1000, bool $is = false)
|
||||||
|
{
|
||||||
|
usleep($interval * 1000);
|
||||||
|
|
||||||
|
$callback();
|
||||||
|
|
||||||
|
interval($callback, $interval, $is);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!function_exists('duplicate')) {
|
if (!function_exists('duplicate')) {
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ use Kiri\Kiri;
|
|||||||
use ReflectionException;
|
use ReflectionException;
|
||||||
use Server\ServerManager;
|
use Server\ServerManager;
|
||||||
use Server\Contract\OnTaskInterface;
|
use Server\Contract\OnTaskInterface;
|
||||||
|
use Server\Tasker\AsyncTaskExecute;
|
||||||
use Swoole\Table;
|
use Swoole\Table;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -210,7 +211,7 @@ abstract class BaseApplication extends Component
|
|||||||
*/
|
*/
|
||||||
public function task(OnTaskInterface $execute): void
|
public function task(OnTaskInterface $execute): void
|
||||||
{
|
{
|
||||||
di(ServerManager::class)->task($execute);
|
di(AsyncTaskExecute::class)->execute($execute);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ namespace Kiri;
|
|||||||
use Exception;
|
use Exception;
|
||||||
use Kiri\Abstracts\Component;
|
use Kiri\Abstracts\Component;
|
||||||
use Server\ServerManager;
|
use Server\ServerManager;
|
||||||
|
use Server\Tasker\AsyncTaskExecute;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Async
|
* Class Async
|
||||||
@@ -36,8 +37,8 @@ class Async extends Component
|
|||||||
*/
|
*/
|
||||||
public function dispatch(string $name, array $params = [])
|
public function dispatch(string $name, array $params = [])
|
||||||
{
|
{
|
||||||
$context = di(ServerManager::class);
|
$context = di(AsyncTaskExecute::class);
|
||||||
$context->task(static::$_absences[$name], $params);
|
$context->execute(static::$_absences[$name], $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -261,7 +261,6 @@ class Container extends BaseObject implements ContainerInterface
|
|||||||
/**
|
/**
|
||||||
* @param $class
|
* @param $class
|
||||||
* @return ReflectionClass
|
* @return ReflectionClass
|
||||||
* @throws ReflectionException
|
|
||||||
*/
|
*/
|
||||||
private function resolveDependencies($class): ReflectionClass
|
private function resolveDependencies($class): ReflectionClass
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -98,14 +98,11 @@ class HotReload extends Command
|
|||||||
public function healthCheck()
|
public function healthCheck()
|
||||||
{
|
{
|
||||||
$pid = (int)file_get_contents(storage('.swoole.pid'));
|
$pid = (int)file_get_contents(storage('.swoole.pid'));
|
||||||
$this->logger->debug('timer ticker.' . $pid . '.' . Process::kill($pid, 0));
|
|
||||||
if (empty($pid)) {
|
if (empty($pid)) {
|
||||||
|
$this->logger->warning('service is shutdown you need reload.');
|
||||||
$this->trigger_reload();
|
$this->trigger_reload();
|
||||||
} else if (!Process::kill($pid, 0)) {
|
} else if (!Process::kill($pid, 0)) {
|
||||||
if ($this->process && Process::kill($this->process->pid, 0)) {
|
$this->logger->warning('service is shutdown you need reload.');
|
||||||
echo 'service is shutdown you need reload.';
|
|
||||||
Process::kill($this->process->pid, -15);
|
|
||||||
}
|
|
||||||
$this->trigger_reload();
|
$this->trigger_reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ use Kiri\Di\Container;
|
|||||||
use Psr\Container\ContainerInterface;
|
use Psr\Container\ContainerInterface;
|
||||||
use ReflectionException;
|
use ReflectionException;
|
||||||
use Server\ServerManager;
|
use Server\ServerManager;
|
||||||
|
use Server\Tasker\AsyncTaskExecute;
|
||||||
use Swoole\Coroutine;
|
use Swoole\Coroutine;
|
||||||
use Swoole\Process;
|
use Swoole\Process;
|
||||||
use Swoole\WebSocket\Server;
|
use Swoole\WebSocket\Server;
|
||||||
@@ -457,8 +458,8 @@ class Kiri
|
|||||||
*/
|
*/
|
||||||
public static function async(string $class, array $params = [])
|
public static function async(string $class, array $params = [])
|
||||||
{
|
{
|
||||||
$manager = di(ServerManager::class);
|
$manager = di(AsyncTaskExecute::class);
|
||||||
$manager->task(new $class(...$params));
|
$manager->execute(new $class(...$params));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -49,3 +49,42 @@
|
|||||||
// after($process);
|
// after($process);
|
||||||
//});
|
//});
|
||||||
|
|
||||||
|
|
||||||
|
var_dump(json_encode([
|
||||||
|
"Datacenter" => "dc1",
|
||||||
|
"Node" => "iz8vbi3edjyskl7kpuwudqz",
|
||||||
|
"SkipNodeUpdate" => false,
|
||||||
|
"Service" => [
|
||||||
|
"ID" => "redis1",
|
||||||
|
"Service" => "FriendRpcService",
|
||||||
|
"Address" => "172.26.221.211",
|
||||||
|
"TaggedAddresses" => [
|
||||||
|
"lan" => [
|
||||||
|
"address" => "127.0.0.1",
|
||||||
|
"port" => 9627
|
||||||
|
],
|
||||||
|
"wan" => [
|
||||||
|
"address" => "172.26.221.211",
|
||||||
|
"port" => 9627
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"Meta" => [
|
||||||
|
"redis_version" => "4.0"
|
||||||
|
],
|
||||||
|
"Port" => 9627
|
||||||
|
],
|
||||||
|
"Check" => [
|
||||||
|
"Node" => "iz8vbi3edjyskl7kpuwudqz",
|
||||||
|
"CheckId" => "service:redis1",
|
||||||
|
"Name" => "Redis health check",
|
||||||
|
"Notes" => "Script based health check",
|
||||||
|
"Status" => "passing",
|
||||||
|
"ServiceID" => "redis1",
|
||||||
|
"Definition" => [
|
||||||
|
"Http" => "http://172.26.221.211:9627",
|
||||||
|
"Interval" => "5s",
|
||||||
|
"Timeout" => "1s",
|
||||||
|
"DeregisterCriticalServiceAfter" => "30s"
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]));
|
||||||
|
|||||||
Reference in New Issue
Block a user