From 113dfd2bc5089c66b7ff5d1ddccbd8c895bdd766 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Mon, 27 Aug 2018 01:53:02 +0200 Subject: Improved server start scripts --- infrastructure/Console/Commands/StartServer.sh | 9 +++++++ .../Console/Commands/StartServerCommand.php | 30 ++++++++++++++++++++++ .../Console/Commands/WebSocketServerCommand.php | 3 +-- infrastructure/Console/Kernel.php | 3 ++- 4 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 infrastructure/Console/Commands/StartServer.sh create mode 100644 infrastructure/Console/Commands/StartServerCommand.php (limited to 'infrastructure') 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 @@ +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 @@ 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 ]; /** -- cgit v1.2.3