-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.pl
38 lines (28 loc) · 924 Bytes
/
main.pl
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
:- module(main, []).
/** <module> The main module */
:- use_module(library(bc/bc_env)).
:- dynamic(started/0).
% Catch uncaught errors/warnings before start and shut down
% when they occur.
user:message_hook(Term, Type, _):-
\+ started,
( Type = error ; Type = warning ),
message_to_string(Term, String),
writeln(user_error, String),
halt(1).
:- use_module(library(bc/bc_main)).
:- use_module(library(bc/bc_type)).
:- use_module(lib/routes).
:- use_module(lib/config).
:- use_module(library(bc/bc_router)).
:- use_module(library(bc/bc_data)).
:- use_module(library(http/http_unix_daemon)).
:- use_module(library(http/thread_httpd)).
% Enables preview for posts.
:- bc_register_preview(post, '/post/<slug>').
% Initialize the serving daemon.
http_unix_daemon:http_server_hook(Options):-
assertz(started),
config(db, File),
bc_data_open(File),
http_server(bc_route, Options).