forked from terminusdb/terminusdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.pl
executable file
·128 lines (105 loc) · 3.62 KB
/
start.pl
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
#!/usr/bin/env swipl
/*
* This file is part of TerminusDB.
*
* TerminusDB 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, under version 3 of the License, or
* (at your option) any later version.
*
* TerminusDB 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 TerminusDB. If not, see <https://www.gnu.org/licenses/>.
*
*/
:- initialization(main).
%! version_string(+Int:integer, -Str:string) is det
%
% convert an integer form version number as supplied by
% the =|version|= flag of =|current_prolog_flag/2|=
% to a string representation
%
version_string(Int, Str) :-
Major is floor( Int / 10_000 ) rem 100,
Minor is floor( Int / 100 ) rem 100,
Patch is Int rem 100,
format(string(Str), '~w.~w.~w', [Major, Minor, Patch]).
:- multifile prolog:message//1.
prolog:message(error(version_error(Correct, Was), _)) -->
{
maplist(version_string, Correct, VersionStrings),
atomic_list_concat(VersionStrings, " or ", AcceptedVersions),
version_string(Was, W)
},
[ 'Run TerminusDB using SWI-Prolog version ~w, you are on ~w'-[AcceptedVersions, W],
nl].
needs_version(80111).
needs_version(80110).
needs_version(80003).
must_be_proper_version :-
current_prolog_flag(version, RunningVersion),
( needs_version(RunningVersion)
-> true
;
findall(Version, needs_version(Version), SupportedVersions),
print_message(error,
error(version_error(SupportedVersions, RunningVersion), terminus_db_startup)),
halt
).
:- initialization must_be_proper_version.
:- dynamic user:file_search_path/2.
:- multifile user:file_search_path/2.
:- prolog_load_context(directory, Dir),
asserta(user:file_search_path(terminus_home, Dir)).
add_library_path :-
user:file_search_path(terminus_home, Dir),
atom_concat(Dir,'/library',Library),
asserta(user:file_search_path(library, Library)).
:- add_library_path.
add_config_path :-
user:file_search_path(terminus_home, Dir),
atom_concat(Dir,'/config',Config),
asserta(user:file_search_path(config, Config)).
:- add_config_path.
add_test_path :-
user:file_search_path(terminus_home, Dir),
atom_concat(Dir,'/test',Config),
asserta(user:file_search_path(test, Config)).
:- add_test_path.
add_plugin_path :-
user:file_search_path(terminus_home, Dir),
atom_concat(Dir,'/plugins',Config),
asserta(user:file_search_path(plugins, Config)).
:- add_plugin_path.
initialise_server_settings :-
file_search_path(terminus_home, BasePath),
!,
atom_concat(BasePath, '/config/config.pl', Settings_Path),
( exists_file(Settings_Path)
-> true
; format("CRITICAL ERROR: Server can't be started because the configuration is missing~n~nRun: ~s/utils/db_util first~n", BasePath),
halt(10)
).
:- initialise_server_settings.
:- use_module(library(api)).
:- use_module(library(server)).
:- use_module(library(upgrade_db)).
:- use_module(library(prefixes)).
% We only need this if we are interactive...
:- use_module(library(sdk)).
:- use_module(test(tests)).
% Plugins
%:- use_module(plugins(registry)).
main(Argv) :-
%maybe_upgrade,
initialise_prefix_db,
initialise_contexts,
server(Argv),
( Argv == [test]
-> run_tests
; true
).