laravel-template/app/Console/Commands/Works.php
2023-11-01 12:02:17 +08:00

42 lines
859 B
PHP

<?php
namespace App\Console\Commands;
use App\Services\PingerService;
use Spiral\RoadRunner\Worker;
use Illuminate\Console\Command;
use Spiral\RoadRunner\GRPC\Server;
use Spiral\RoadRunner\GRPC\Invoker;
use App\Services\gRPC\Pinger\PingerInterface;
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());
}
}