This commit is contained in:
2021-10-29 11:06:52 +08:00
parent 286d06a42a
commit a8cd5d59fc
+11 -4
View File
@@ -6,8 +6,10 @@ use Annotation\Annotation;
use Annotation\Inject; use Annotation\Inject;
use Http\Handler\Router; use Http\Handler\Router;
use Kiri\Abstracts\Component; use Kiri\Abstracts\Component;
use Kiri\Abstracts\Config;
use Kiri\Consul\Agent; use Kiri\Consul\Agent;
use Kiri\Di\NoteManager; use Kiri\Di\NoteManager;
use Kiri\Exception\ConfigException;
use Kiri\Kiri; use Kiri\Kiri;
use Server\SInterface\OnCloseInterface; use Server\SInterface\OnCloseInterface;
use Server\SInterface\OnConnectInterface; use Server\SInterface\OnConnectInterface;
@@ -60,22 +62,27 @@ class RpcJsonp extends Component implements OnConnectInterface, OnReceiveInterfa
} }
/**
* @throws ConfigException
*/
public function register() public function register()
{ {
$config = Config::get('rpc');
$agent = Kiri::getDi()->get(Agent::class); $agent = Kiri::getDi()->get(Agent::class);
$agent->service->register([ $agent->service->register([
"ID" => "redis1", "ID" => $config['name'] ?? 'test-name',
"Name" => "redis", "Name" => "redis",
"Tags" => ["primary", "v1"], "Tags" => ["primary", "v1"],
"Address" => "127.0.0.1", "Address" => Kiri::localhost(),
"Port" => 8000, "Port" => $config['port'],
"Meta" => [ "Meta" => [
"redis_version" => "4.0" "redis_version" => "4.0"
], ],
"EnableTagOverride" => false, "EnableTagOverride" => false,
"Check" => [ "Check" => [
"DeregisterCriticalServiceAfter" => "90m", "DeregisterCriticalServiceAfter" => "90m",
// "Args" => ["/usr/local/bin/check_redis.py"], // "Args" => ["/usr/local/bin/check_redis.py"],
"Interval" => "10s", "Interval" => "10s",
"Timeout" => "5s" "Timeout" => "5s"
], ],