http_server as daemon

38 views
Skip to first unread message

Jose Antonio Espinosa

unread,
Nov 6, 2015, 6:18:46 AM11/6/15
to SWI-Prolog
Hello,

I'm using aroute library to develop a small http interface. Everything is ok and I start the server with:

http_server(route, [port(8008)]).

I want the server still up in a linux machine, but I cannot make the swipl process run in the background. I tried the http_daemon, but I am unable to know how to pass the router to http_daemon

I'm very new to swi, so it is possible I just have not read all the information. But I need have the http server running in non interactive mode in the background.

Regards

Jan Wielemaker

unread,
Nov 6, 2015, 6:51:38 AM11/6/15
to Jose Antonio Espinosa, SWI-Prolog
On 11/06/2015 12:18 PM, Jose Antonio Espinosa wrote:
> Hello,
>
> I'm using aroute library to develop a small http interface. Everything
> is ok and I start the server with:
>
> http_server(route, [port(8008)]).
>
> I want the server still up in a linux machine, but I cannot make the
> swipl process run in the background. I tried the http_daemon, but I am
> unable to know how to pass the router to http_daemon

I think the daemon code is hard coded to call the http_dispatch router.

> I'm very new to swi, so it is possible I just have not read all the
> information. But I need have the http server running in non interactive
> mode in the background.

Most of the rest in the daemon code is useful for a proper daemon though
(command line arguments, syslog, user management, etc.). If you just
want to avoid stopping, you must prevent Prolog to return to the
toplevel. You can do so by calling e.g., thread_get_message(quit).
So,

server(Port) :-
http_server(route, [port(8008)]),
thread_get_message(quit).

Cheers --- Jan

>
> Regards
>
> --
> You received this message because you are subscribed to the Google
> Groups "SWI-Prolog" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to swi-prolog+...@googlegroups.com
> <mailto:swi-prolog+...@googlegroups.com>.
> Visit this group at http://groups.google.com/group/swi-prolog.
> For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages