I want to open a connection to Postgresql with ODBC when I fire up a http server using something like
swipl server.pl --port=3030 --pidfile=http.pid
and close it when I do kill $(cat http.pid)
Would this work?
:- use_module(library(http/http_unix_daemon)).
:- initialization(run, main).
run :-
setup_call_cleanup(
odbc_connect(dbname, _, [alias(dbname)]),
http_daemon,
odbc_disconnect(dbname)
).