### ----------------------------------------------------
### -- cro
### -- Licenses: Artistic-2.0
### -- Authors: Jonathan Worthington <jnthn@jnthn.net>
### -- File: t/tools-services-test-dir/service1/service.raku
### ----------------------------------------------------
use Cro::HTTP::Router;
use Cro::HTTP::Server;
use Cro::HTTP::Log::File;

my $routes = route {
    get -> {
        content 'text/plain', 'Service 1 OK';
    }
}

my Cro::Service $http = Cro::HTTP::Server.new(
    http => '1.1',
    host => %*ENV<SERVICE1_HTTP_HOST> ||
        die("Missing SERVICE1_HTTP_HOST in environment"),
    port => %*ENV<SERVICE1_HTTP_PORT> ||
        die("Missing SERVICE1_HTTP_PORT in environment"),
    application => $routes,
    after => [
        Cro::HTTP::Log::File.new(logs => $*OUT, errors => $*ERR)
    ]
);
$http.start;
react {
    whenever signal(SIGINT) {
        $http.stop;
        done;
    }
}


