Skip to content

Commit

Permalink
Set dashboard at runtime
Browse files Browse the repository at this point in the history
Set dashboard path at runtime to allow AppImage dashboard to work
  • Loading branch information
rrooij committed Dec 2, 2022
1 parent e463e43 commit f443921
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 16 deletions.
2 changes: 1 addition & 1 deletion distribution/appimage/build_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mkdir -p app_dir/usr/share/terminusdb
mkdir -p app_dir/usr/bin
mkdir -p app_dir/usr/lib/x86_64-linux-gnu
# Build TerminusDB
cd ../../ && make install-deps && make && cd "$CURRENT_DIR"
cd ../../ && make install-dashboard && make install-deps && make && cd "$CURRENT_DIR"
# Copy relevant files back to appimage dir
cp -r ../../terminusdb ../../dashboard app_dir/usr/share/terminusdb/
cp -r /usr/lib/swi-prolog app_dir/usr/lib/
Expand Down
4 changes: 4 additions & 0 deletions src/config/terminus_config.pl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
:- module(config,[
terminusdb_version/1,
dashboard_path/1,
bootstrap_config_files/0,
server/1,
server_name/1,
Expand Down Expand Up @@ -46,6 +47,9 @@
terminusdb_version('10.1.10').
/* [[[end]]] */

dashboard_path(Path) :-
getenv('TERMINUSDB_DASHBOARD_PATH', Path).

bootstrap_config_files :-
initialize_system_ssl_certs.

Expand Down
1 change: 1 addition & 0 deletions src/core/api.pl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
:- module(api, [
% init.pl
bootstrap_files/0,
add_dashboard_path/0,
index_template/1,
initialize_flags/0,
initialize_database/2,
Expand Down
14 changes: 14 additions & 0 deletions src/core/api/api_init.pl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
:- module(api_init, [
bootstrap_files/0,
add_dashboard_path/0,
initialize_flags/0,
initialize_database/2,
initialize_database_with_store/2,
Expand Down Expand Up @@ -121,6 +122,19 @@
db_path(DB_Path),
initialize_database_with_path(Key, DB_Path, Force).

assert_dashboard_path(Dir) :-
directory_file_path(Dir, 'assets', Assets),
asserta(user:file_search_path(dashboard, Dir)),
asserta(user:file_search_path(assets, Assets)).

add_dashboard_path :-
config:dashboard_path(Dir),
assert_dashboard_path(Dir).
add_dashboard_path :-
user:file_search_path(terminus_top_dir, Dir),
directory_file_path(Dir, 'dashboard', Dashboard),
assert_dashboard_path(Dashboard).

/*
* initialize_database_with_path(Key,DB_Path,Force) is det+error.
*
Expand Down
21 changes: 6 additions & 15 deletions src/load_paths.pl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
prolog_load_context(file, File),
relative_file_name(Path, File, '..').

add_terminus_top_dir :-
top_level_directory(TopDir),
asserta(user:file_search_path(terminus_top_dir, TopDir)).

:- add_terminus_top_dir.

add_terminus_home_path :-
top_level_directory(TopDir),
directory_file_path(TopDir, 'src', SrcDir),
Expand Down Expand Up @@ -122,21 +128,6 @@
directory_file_path(Dir, 'terminusdb-enterprise/test', Enterprise),
asserta(user:file_search_path(enterprise_test, Enterprise)).

assert_dashboard_path(Dir) :-
directory_file_path(Dir, 'assets', Assets),
asserta(user:file_search_path(dashboard, Dir)),
asserta(user:file_search_path(assets, Assets)).

add_dashboard_path :-
getenv('TERMINUSDB_DASHBOARD_PATH', Dir),
assert_dashboard_path(Dir).
add_dashboard_path :-
top_level_directory(Dir),
directory_file_path(Dir, 'dashboard', Dashboard),
assert_dashboard_path(Dashboard).

:- add_dashboard_path.

:- if(getenv("TERMINUSDB_ENTERPRISE", true)).
:- add_enterprise_path.
:- add_enterprise_test_path.
Expand Down
1 change: 1 addition & 0 deletions src/server/main.pl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
server(Server),
server_port(Port),
worker_amount(Workers),
add_dashboard_path,
load_jwt_conditionally,
HTTPOptions = [port(Port), workers(Workers)],
foreach(pre_server_startup_hook(Port),true),
Expand Down

0 comments on commit f443921

Please sign in to comment.