summary refs log tree commit diff stats
path: root/server/service.raku
diff options
context:
space:
mode:
Diffstat (limited to 'server/service.raku')
-rw-r--r--server/service.raku33
1 files changed, 33 insertions, 0 deletions
diff --git a/server/service.raku b/server/service.raku
new file mode 100644
index 0000000..2a41f5b
--- /dev/null
+++ b/server/service.raku
@@ -0,0 +1,33 @@
+use Cro::HTTP::Server;
+use Cro::HTTP::Router;
+use Cro::HTTP::Log::File;
+
+unit sub MAIN(
+    Bool :$debug = True, #= enable debug mode
+);
+
+my $application = route {
+};
+
+my $host = 0.0.0.0;
+my $port = 9090;
+
+my Cro::Service $http = Cro::HTTP::Server.new(
+    http => <1.1>,
+    host => $host,
+    port => $port,
+    :$application,
+    after => [
+              Cro::HTTP::Log::File.new(logs => $*OUT, errors => $*ERR)
+          ]
+);
+$http.start;
+put "Listening at http://{$host}:{$port}";
+
+react {
+    whenever signal(SIGINT) {
+        say "Shutting down...";
+        $http.stop;
+        done;
+    }
+}