1#!/usr/local/bin/swipl
    2
    3:- module(logicmoo_swish, [ ]).    4
    5:- use_module(library(http/thread_httpd)).    6:- use_module(library(http/http_dispatch)).    7:- use_module(library(broadcast)).    8% :- user:use_module(library(logicmoo_utils)).
    9
   10%:- baseKB:use_module(library(pfc_lib)).
   11
   12% :- baseKB:use_module(library(logicmoo_clif)).
   13
   14:- multifile sandbox:safe_primitive/1.   15
   16sandbox:safe_primitive(tlbugger:rtracing).
   17sandbox:safe_primitive(tlbugger:dont_skip_bugger).
   18sandbox:safe_primitive(tlbugger:skip_bugger).
   19sandbox:safe_primitive(tlbugger:skipMust).
   20:- forall(current_predicate(tlbugger:P),asserta(sandbox:safe_primitive(tlbugger:P))).   21
   22
   23:- set_prolog_flag(no_sandbox, true).   24
   25% :- initialization(user:run_swish, program).
   26:- remove_undef_search.   27%:- tdebug.
   28%:- guitracer.
   29:- add_history((repeat,sleep(10),make,join_threads,fail)).   30% :- interactor.
   31run_logicmoo_swish:- 
   32    set_prolog_flag(toplevel_goal, prolog),
   33    current_prolog_flag(argv, Argv),
   34    argv_options(Argv, _, Options),
   35    option(port(Port), Options, 3020),
   36    (   option((public true), Options)
   37    ->  Address=Port
   38    ;   Address=localhost:Port
   39    ),
   40    broadcast(http(pre_server_start)),
   41	http_server(http_dispatch,
   42		    [ port(Address),
   43		      workers(6)
   44		    ]),
   45	broadcast(http(post_server_start))