diff options
Diffstat (limited to 'infrastructure')
-rw-r--r-- | infrastructure/Console/Commands/StartServer.sh | 9 | ||||
-rw-r--r-- | infrastructure/Console/Commands/StartServerCommand.php | 30 | ||||
-rw-r--r-- | infrastructure/Console/Commands/WebSocketServerCommand.php | 3 | ||||
-rw-r--r-- | infrastructure/Console/Kernel.php | 3 |
4 files changed, 42 insertions, 3 deletions
diff --git a/infrastructure/Console/Commands/StartServer.sh b/infrastructure/Console/Commands/StartServer.sh new file mode 100644 index 0000000..f9feaa8 --- /dev/null +++ b/infrastructure/Console/Commands/StartServer.sh @@ -0,0 +1,9 @@ +#!/bin/bash -e +redis-server & +PIDS[0]=$! +sudo php artisan serve --host 0.0.0.0 --port 80 & +PIDS[1]=$! + +trap "sudo kill ${PIDS[*]}" SIGINT + +wait diff --git a/infrastructure/Console/Commands/StartServerCommand.php b/infrastructure/Console/Commands/StartServerCommand.php new file mode 100644 index 0000000..03ec6f9 --- /dev/null +++ b/infrastructure/Console/Commands/StartServerCommand.php @@ -0,0 +1,30 @@ +<?php + +namespace Infrastructure\Console\Commands; + +use Illuminate\Console\Command; + +class StartServerCommand extends Command +{ + /** + * The console command name. + * + * @var string + */ + protected $name = 'server'; + + /** + * Execute the console command. + * + * @return void + */ + public function fire() + { + $this->line('Starting server...'); + if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { + exec("wsl bash infrastructure/Console/Commands/StartServer.sh"); + } else { + exec("bash infrastructure/Console/Commands/StartServer.sh"); + } + } +}
\ No newline at end of file diff --git a/infrastructure/Console/Commands/WebSocketServerCommand.php b/infrastructure/Console/Commands/WebSocketServerCommand.php index 4723b29..764e16a 100644 --- a/infrastructure/Console/Commands/WebSocketServerCommand.php +++ b/infrastructure/Console/Commands/WebSocketServerCommand.php @@ -1,5 +1,4 @@ <?php - namespace Infrastructure\Console\Commands; use Illuminate\Console\Command; @@ -32,7 +31,7 @@ class WebSocketServerCommand extends Command ), 1337 ); - $this->line('Started server.'); + $this->line('Starting websocket...'); $server->run(); } }
\ No newline at end of file diff --git a/infrastructure/Console/Kernel.php b/infrastructure/Console/Kernel.php index 13329ae..61173ff 100644 --- a/infrastructure/Console/Kernel.php +++ b/infrastructure/Console/Kernel.php @@ -15,7 +15,8 @@ class Kernel extends ConsoleKernel */ protected $commands = [ AddUserCommand::class, - Commands\WebSocketServerCommand::class + Commands\WebSocketServerCommand::class, + Commands\StartServerCommand::class ]; /** |