diff --git a/app/Console/Commands/StartServer.php b/app/Console/Commands/StartServer.php index 476ca44..36531aa 100644 --- a/app/Console/Commands/StartServer.php +++ b/app/Console/Commands/StartServer.php @@ -36,27 +36,34 @@ class StartServer extends Command { $o = Setup::findOrFail(config('app.id')); - // @todo This should be a config item. - $start = [ - 'emsi' => [ - 'address'=>Setup::EMSI_BIND, - 'port'=>Setup::EMSI_PORT, - 'class'=>new EMSI($o), + $start = collect(); - ], - 'binkp' => [ + if ($o->optionGet(Setup::O_BINKP)) + $start->put('binkp',[ 'address'=>Setup::BINKP_BIND, 'port'=>Setup::BINKP_PORT, 'class'=>new Binkp($o), - ], - ]; + ]); + + if ($o->optionGet(Setup::O_EMSI)) + $start->put('emsi',[ + 'address'=>Setup::EMSI_BIND, + 'port'=>Setup::EMSI_PORT, + 'class'=>new EMSI($o), + ]); $children = collect(); Log::debug(sprintf('%s:+ Starting Servers...',__METHOD__)); + + if (! $start->count()) { + Log::alert(sprintf('%s: - No servers configured to start',__METHOD__)); + return; + } + pcntl_signal(SIGCHLD,SIG_IGN); - foreach ($start as $item => $config) { + foreach ($start->toArray() as $item => $config) { Log::debug(sprintf('%s: - Starting: [%s]',__METHOD__,$item)); $pid = pcntl_fork(); @@ -91,11 +98,14 @@ class StartServer extends Command } // Wait for children to exit - while ($children->count()) { + while ($x=$children->count()) { // Wait for children to finish $exited = pcntl_wait($status); - Log::info(sprintf('%s: - Exited: [%s]',__METHOD__,$children->pull($exited))); + if ($exited < 0) + abort(500,'Something strange for status: '.serialize($status)); + + Log::info(sprintf('%s: - Exited: #%d [%s]',__METHOD__,$x,$children->pull($exited))); } // Done diff --git a/resources/views/setup.blade.php b/resources/views/setup.blade.php index df11d0b..b198dbe 100644 --- a/resources/views/setup.blade.php +++ b/resources/views/setup.blade.php @@ -100,7 +100,7 @@ use App\Models\Setup;

BINKP Settings

-

Bink has been configured to listen on {{ Setup::BINKP_BIND }}:{{ Setup::BINKP_PORT }}

+

BINKD has been configured to listen on {{ Setup::BINKP_BIND }}:{{ Setup::BINKP_PORT }}

optionGet(Setup::O_BINKP))) checked @endif> @@ -149,6 +149,7 @@ use App\Models\Setup;

* Recommended Defaults

+ {{-- $this->binkp_options = ['m','d','r','b']; @@ -159,7 +160,7 @@ use App\Models\Setup;

EMSI Settings

-

Bink has been configured to listen on {{ Setup::EMSI_BIND }}:{{ Setup::EMSI_PORT }}

+

EMSI has been configured to listen on {{ Setup::EMSI_BIND }}:{{ Setup::EMSI_PORT }}

optionGet(Setup::O_EMSI))) checked @endif>