This repository has been archived by the owner on Feb 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathservice.p6
54 lines (48 loc) · 1.68 KB
/
service.p6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
use Doc::TypeGraph;
use Doc::TypeGraph::Viz;
use Documentable;
use Documentable::Registry;
use Cro::HTTP::Log::File;
use Cro::HTTP::Server;
use Docky::Host;
use Docky::Routes;
use Docky::Search;
use Docky::CacheHeater;
my $host = Docky::Host.new;
init-search($host);
unless 'static/images'.IO.e {
mkdir 'static/images/light';
mkdir 'static/images/dark';
my $tg = Doc::TypeGraph.new-from-file;
# Write light colors
my $viz = Doc::TypeGraph::Viz.new(class-color => '#030303', role-color => '#5503B3', enum-color => '#A30031',
bg-color => '#fafafa', node-style => 'filled margin=0.2 fillcolor="#f2f2f2" shape=rectangle fontsize=16');
$viz.write-type-graph-images(path => "static/images/light", :force, type-graph => $tg);
# Write dark colors
$viz = Doc::TypeGraph::Viz.new(class-color => '#f7f7f7', role-color => '#8DB2EB', enum-color => '#EED891',
bg-color => '#1B1D1E', node-style => 'filled margin=0.2 fillcolor="#212426" shape=rectangle fontsize=16');
$viz.write-type-graph-images(path => "static/images/dark", :force, type-graph => $tg);
}
my Cro::Service $http = Cro::HTTP::Server.new(
http => <1.1>,
host => %*ENV<DOCKY_HOST> ||
die("Missing DOCKY_HOST in environment"),
port => %*ENV<DOCKY_PORT> ||
die("Missing DOCKY_PORT in environment"),
application => routes($host),
after => [
Cro::HTTP::Log::File.new(logs => $*OUT, errors => $*ERR)
]
);
$http.start;
say "Listening at http://%*ENV<DOCKY_HOST>:%*ENV<DOCKY_PORT>";
if %*ENV<PRODUCTION_ENV> {
Docky::CacheHeater.heat-cache($host);
}
react {
whenever signal(SIGINT) {
say "Shutting down...";
$http.stop;
done;
}
}