Skip to content

Commit

Permalink
Added host property and made port optional
Browse files Browse the repository at this point in the history
  • Loading branch information
Xantios Krugor authored and Xantios Krugor committed Jul 3, 2021
1 parent 5f4a495 commit 259a412
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 14 deletions.
52 changes: 42 additions & 10 deletions maple-config.example.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,46 @@
<?php

return [
[
'name' => "Some long running thing",
'retries' => 3,
'autostart' => true
],
[
'name' => "Some process that keeps on exiting but needs to be running",
'reties' => -1,
'autostart' => true

// Host to listen on (defaults to 127.0.0.1)
# 'host' => '0.0.0.0',

// Port for web interface to listen on (defaults to 8100)
# 'port' => 8100,

// Verbose logging
'verbose' => true,

// Tasks available
'tasks' => [
[
'name' => "Run webpack",
'retries' => 0,
'autostart' => true,
'cmd' => 'sleep 10'
],
[
'name' => "Some process that keeps on exiting but needs to be running",
'retries' => -1,
'autostart' => true,
'cmd' => 'ping -t 3 8.8.8.8 ; sleep 5'
],
// Run multiple tasks back-to-back
[
'name' => 'Jan-1',
'after' => 'Jan-2',
'autostart' => true,
'cmd' => 'sleep 1',
],
[
'name' => 'Jan-2',
'after' => 'Jan-3',
'cmd' => 'sleep 1',
],
[
'name' => 'Jan-3',
'after' => '',
'cmd' => 'sleep 1',
]
]
];
];
7 changes: 5 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ The configuration file is a plain PHP array, it is pretty self-explanatory
<?php

return [
// Port for web interface to listen on
'port' => 8100,
// Host to listen on (defaults to 127.0.0.1)
# 'host' => '0.0.0.0',

// Port for web interface to listen on (defaults to 8100)
# 'port' => 8100,

// Verbose logging
'verbose' => true,
Expand Down
7 changes: 5 additions & 2 deletions src/HttpServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@
class HttpServer {

private int $port;
private string $host;

private LoopInterface $loop;
private Server $server;
private OutputInterface $output;

public function __construct(array $config,LoopInterface $loop,OutputInterface $output) {

$this->port = $config['port'];
$this->port = (isset($config['port'])) ? $config['port'] : '8100';
$this->host = (isset($config['host'])) ? $config['host'] : '127.0.0.1';

$this->loop = $loop;
$this->output = $output;

Expand Down Expand Up @@ -52,7 +55,7 @@ public function __construct(array $config,LoopInterface $loop,OutputInterface $o
public function run(): void
{
$socket = new \React\Socket\Server($this->port,$this->loop);
$this->output->writeln('<info>Listening on port '.$this->port.'</info>');
$this->output->writeln('<info>Listening on '.$this->host.":".$this->port.'</info>');
$this->server->listen($socket);
}

Expand Down

0 comments on commit 259a412

Please sign in to comment.