Files
expose/app/Commands/ServeCommand.php
Marcel Pociot 8cda0a62ee wip
2020-06-14 22:19:42 +02:00

40 lines
1.1 KiB
PHP

<?php
namespace App\Commands;
use App\Server\Factory;
use LaravelZero\Framework\Commands\Command;
use React\EventLoop\LoopInterface;
class ServeCommand extends Command
{
protected $signature = 'serve {hostname=localhost} {host=0.0.0.0} {--validateAuthTokens} {--port=8080}';
protected $description = 'Start the expose server';
public function handle()
{
/** @var LoopInterface $loop */
$loop = app(LoopInterface::class);
$loop->futureTick(function () {
$this->info("Expose server running on port ".$this->option('port').".");
});
$validateAuthTokens = config('expose.admin.validate_auth_tokens');
if ($this->option('validateAuthTokens') === true) {
$validateAuthTokens = true;
}
(new Factory())
->setLoop($loop)
->setHost($this->argument('host'))
->setPort($this->option('port'))
->setHostname($this->argument('hostname'))
->validateAuthTokens($validateAuthTokens)
->createServer()
->run();
}
}