laravel-template/app/Console/Commands/Works.php

42 lines
859 B
PHP
Raw Normal View History

2023-11-01 04:02:17 +00:00
<?php
namespace App\Console\Commands;
2023-11-02 13:03:39 +00:00
use App\Services\gRPC\Pinger\PingerInterface;
2023-11-01 04:02:17 +00:00
use App\Services\PingerService;
use Illuminate\Console\Command;
use Spiral\RoadRunner\GRPC\Invoker;
2023-11-02 13:03:39 +00:00
use Spiral\RoadRunner\GRPC\Server;
use Spiral\RoadRunner\Worker;
2023-11-01 04:02:17 +00:00
class Works extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:works';
/**
* The console command description.
*
* @var string
*/
protected $description = '启动 gRPC 服务';
/**
* Execute the console command.
*/
public function handle()
{
$server = new Server(new Invoker(), [
'debug' => false,
]);
$server->registerService(PingerInterface::class, new PingerService());
$server->serve(Worker::create());
}
}