Blog-Core framework

Fork me on GitHub

Running with http_unix_daemon

There might be cases when you want to run the application through the http_unix_daemon module which provides self-daemonization support on *nix systems. This can be accomplished with the following code:

:- use_module(library(bc/bc_main)).
:- 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)).

:- use_module('your other modules ...').

http_unix_daemon:http_server_hook(Options):-
    http_server(bc_route, Options).

:- dynamic(started/0).

start:-
    started, !.

start:-
    bc_data_open('blog.docstore'),
    http_daemon,
    assertz(started).

:- start.

The started predicate protects against multiple activations which raise from the make. goal. The module bc_main must be loaded although nothing is called from there. The module provides environment setup.