-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathload.pl
More file actions
145 lines (128 loc) · 4.62 KB
/
load.pl
File metadata and controls
145 lines (128 loc) · 4.62 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/* Part of SWI-Prolog web site
Author: Jan Wielemaker
E-mail: jan@swi-prolog.org
WWW: https://www.swi-prolog.org
Copyright (C): 2009-2025, SWI-Prolog Solutions b.v.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
As a special exception, if you link this library with other files,
compiled with a Free Software compiler, to produce an executable, this
library does not by itself cause the resulting executable to be covered
by the GNU General Public License. This exception does not however
invalidate any other reasons why the executable file might be covered by
the GNU General Public License.
*/
:- dynamic
pre_files/1.
:- findall(F, source_file(F), FL),
assertz(pre_files(FL)).
:- doc_collect(true).
:- attach_packs(packs, [duplicate(replace)]).
:- load_files([ library(pldoc/doc_library),
library(thread_pool),
library(http/http_session),
library(http/http_unix_daemon),
library(http/http_dyn_workers),
library(prolog_source),
well_known,
plweb,
examples,
blog,
api,
wiki_edit,
stats,
pack,
register,
changelog,
tagit,
forum,
make,
test_recaptcha,
watchdog
]).
:- if(exists_source(library(ssh_server))).
:- use_module(library(ssh_server)).
:- use_module(library(broadcast)).
:- listen(http(pre_server_start),
start_sshd).
start_sshd :-
absolute_file_name(private('etc/ssh/authorized_keys'), File,
[ access(read)]),
absolute_file_name(private('etc/ssh/ssh_host_ecdsa_key'), HostKey,
[ access(read)]),
ssh_server([ port(2022),
bind_address(*),
authorized_keys_file(File),
host_key_file(HostKey)
]).
:- endif.
%! read_comments(+File)
%
% Reads PlDoc comments for a file that was already loaded before
% the server was started.
read_comments(File) :-
access_file(File, read),
source_file_property(File, module(M)),
!,
setup_call_cleanup(
( prolog_open_source(File, In),
set_prolog_flag(xref, true),
'$set_source_module'(Old, M)
),
( repeat,
prolog_read_source_term(In, Term, _,
[ process_comment(true)
]),
Term == end_of_file,
!
),
( '$set_source_module'(_, Old),
set_prolog_flag(xref, false),
prolog_close_source(In)
)).
read_comments(_). % not a module, we do not care
reload_pre_files :-
pre_files(FL),
forall(member(F, FL),
read_comments(F)).
:- reload_pre_files.
:- doc_load_library.
:- http_set_session_options([enabled(false)]).
:- send(@(pce), catch_error_signals, @(off)).
%! show_fd
%
% Show open file descriptors. Sanity-check that works only on
% Linux systems.
show_fd :-
current_prolog_flag(pid, Pid),
format(string(Cmd),
'/bin/sh -c "(cd /proc/~w/fd && ls -l | grep socket)"',
[Pid]),
shell(Cmd).
show_pools :-
format('~`-t~52|~n'),
format('~w~t~20|~t~w~8+~t~w~8+~t~w~8+~t~w~8+~n',
[ 'Pool name', 'Running', 'Size', 'Waiting', 'Backlog' ]),
format('~`-t~52|~n'),
forall(current_thread_pool(Pool), show_pool(Pool)),
format('~`-t~52|~n').
show_pool(Pool) :-
findall(P, thread_pool_property(Pool, P), List),
memberchk(size(Size), List),
memberchk(running(Running), List),
memberchk(backlog(Waiting), List),
memberchk(options(Options), List),
option(backlog(MaxBackLog), Options, infinite),
format('~w~t~20|~t~D ~8+~t~D ~8+~t~D ~8+~t~w ~8+~n',
[Pool, Running, Size, Waiting, MaxBackLog]).
stop :-
halt(42).