24
24
CONTROLLER_TARGET_NAME ,
25
25
DB_COMPONENT_NAME ,
26
26
FILES_TABLE_SUFFIX ,
27
- LOG_VIEWER_WEBUI_COMPONENT_NAME ,
28
27
QUERY_JOBS_TABLE_NAME ,
29
28
QUERY_SCHEDULER_COMPONENT_NAME ,
30
29
QUERY_WORKER_COMPONENT_NAME ,
57
56
validate_and_load_queue_credentials_file ,
58
57
validate_and_load_redis_credentials_file ,
59
58
validate_db_config ,
60
- validate_log_viewer_webui_config ,
61
59
validate_queue_config ,
62
60
validate_redis_config ,
63
61
validate_reducer_config ,
@@ -843,132 +841,62 @@ def read_and_update_settings_json(settings_file_path: pathlib.Path, updates: Dic
843
841
return settings_object
844
842
845
843
846
- def start_webui (instance_id : str , clp_config : CLPConfig , mounts : CLPDockerMounts ):
844
+ def start_webui (
845
+ instance_id : str ,
846
+ clp_config : CLPConfig ,
847
+ container_clp_config : CLPConfig ,
848
+ mounts : CLPDockerMounts ,
849
+ ):
847
850
component_name = WEBUI_COMPONENT_NAME
848
851
logger .info (f"Starting { component_name } ..." )
849
852
850
853
container_name = f"clp-{ component_name } -{ instance_id } "
851
854
if container_exists (container_name ):
852
855
return
853
856
854
- webui_logs_dir = clp_config .logs_directory / component_name
855
857
container_webui_dir = CONTAINER_CLP_HOME / "var" / "www" / "webui"
856
- node_path = str (container_webui_dir / "programs" / " server" / "npm " / "node_modules" )
857
- settings_json_path = get_clp_home () / "var" / "www" / "webui" / "settings.json"
858
-
859
- validate_webui_config ( clp_config , webui_logs_dir , settings_json_path )
860
-
861
- # Create directories
862
- webui_logs_dir . mkdir ( exist_ok = True , parents = True )
858
+ node_path = str (container_webui_dir / "server" / "node_modules" )
859
+ client_settings_json_path = (
860
+ get_clp_home () / "var" / "www" / "webui" / "client" / "settings.json"
861
+ )
862
+ server_settings_json_path = (
863
+ get_clp_home () / "var" / "www" / "webui" / "server" / "dist" / "server" / "settings.json"
864
+ )
863
865
864
- container_webui_logs_dir = pathlib . Path ( "/" ) / "var" / "log" / component_name
866
+ validate_webui_config ( clp_config , client_settings_json_path , server_settings_json_path )
865
867
866
- # Read and update settings.json
868
+ # Read, update, and write back client's and server's settings.json
867
869
clp_db_connection_params = clp_config .database .get_clp_connection_params_and_type (True )
868
870
table_prefix = clp_db_connection_params ["table_prefix" ]
869
871
if StorageEngine .CLP_S == clp_config .package .storage_engine :
870
872
table_prefix = f"{ table_prefix } { CLP_DEFAULT_DATASET_NAME } _"
871
- meteor_settings_updates = {
872
- "private" : {
873
- "SqlDbHost" : clp_config .database .host ,
874
- "SqlDbPort" : clp_config .database .port ,
875
- "SqlDbName" : clp_config .database .name ,
876
- "SqlDbClpArchivesTableName" : f"{ table_prefix } { ARCHIVES_TABLE_SUFFIX } " ,
877
- "SqlDbClpFilesTableName" : f"{ table_prefix } { FILES_TABLE_SUFFIX } " ,
878
- "SqlDbCompressionJobsTableName" : COMPRESSION_JOBS_TABLE_NAME ,
879
- "SqlDbQueryJobsTableName" : QUERY_JOBS_TABLE_NAME ,
880
- },
881
- "public" : {
882
- "ClpStorageEngine" : clp_config .package .storage_engine ,
883
- "LogViewerWebuiUrl" : (
884
- f"http://{ clp_config .log_viewer_webui .host } :{ clp_config .log_viewer_webui .port } " ,
885
- ),
886
- },
873
+ client_settings_json_updates = {
874
+ "ClpStorageEngine" : clp_config .package .storage_engine ,
875
+ "MongoDbSearchResultsMetadataCollectionName" : clp_config .webui .results_metadata_collection_name ,
876
+ "SqlDbClpArchivesTableName" : f"{ table_prefix } { ARCHIVES_TABLE_SUFFIX } " ,
877
+ "SqlDbClpFilesTableName" : f"{ table_prefix } { FILES_TABLE_SUFFIX } " ,
878
+ "SqlDbCompressionJobsTableName" : COMPRESSION_JOBS_TABLE_NAME ,
887
879
}
888
- meteor_settings = read_and_update_settings_json (settings_json_path , meteor_settings_updates )
889
-
890
- # Start container
891
- # fmt: off
892
- container_cmd = [
893
- "docker" , "run" ,
894
- "-d" ,
895
- "--network" , "host" ,
896
- "--name" , container_name ,
897
- "--log-driver" , "local" ,
898
- "-u" , f"{ os .getuid ()} :{ os .getgid ()} " ,
899
- ]
900
- # fmt: on
901
- env_vars = [
902
- f"NODE_PATH={ node_path } " ,
903
- f"MONGO_URL={ clp_config .results_cache .get_uri ()} " ,
904
- f"PORT={ clp_config .webui .port } " ,
905
- f"ROOT_URL=http://{ clp_config .webui .host } " ,
906
- f"METEOR_SETTINGS={ json .dumps (meteor_settings )} " ,
907
- f"CLP_DB_USER={ clp_config .database .username } " ,
908
- f"CLP_DB_PASS={ clp_config .database .password } " ,
909
- f"WEBUI_LOGS_DIR={ container_webui_logs_dir } " ,
910
- f"WEBUI_LOGGING_LEVEL={ clp_config .webui .logging_level } " ,
911
- ]
912
- necessary_mounts = [
913
- mounts .clp_home ,
914
- DockerMount (DockerMountType .BIND , webui_logs_dir , container_webui_logs_dir ),
915
- ]
916
- append_docker_options (container_cmd , necessary_mounts , env_vars )
917
- container_cmd .append (clp_config .execution_container )
918
-
919
- node_cmd = [
920
- str (CONTAINER_CLP_HOME / "bin" / "node-14" ),
921
- str (container_webui_dir / "launcher.js" ),
922
- str (container_webui_dir / "main.js" ),
923
- ]
924
- cmd = container_cmd + node_cmd
925
- subprocess .run (cmd , stdout = subprocess .DEVNULL , check = True )
926
-
927
- logger .info (f"Started { component_name } ." )
928
-
929
-
930
- def start_log_viewer_webui (
931
- instance_id : str ,
932
- clp_config : CLPConfig ,
933
- container_clp_config : CLPConfig ,
934
- mounts : CLPDockerMounts ,
935
- ):
936
- component_name = LOG_VIEWER_WEBUI_COMPONENT_NAME
937
- logger .info (f"Starting { component_name } ..." )
938
-
939
- container_name = f"clp-{ component_name } -{ instance_id } "
940
- if container_exists (container_name ):
941
- return
942
-
943
- container_log_viewer_webui_dir = CONTAINER_CLP_HOME / "var" / "www" / "log-viewer-webui"
944
- node_path = str (container_log_viewer_webui_dir / "server" / "node_modules" )
945
- settings_json_path = (
946
- get_clp_home ()
947
- / "var"
948
- / "www"
949
- / "log-viewer-webui"
950
- / "server"
951
- / "dist"
952
- / "server"
953
- / "settings.json"
880
+ client_settings_json = read_and_update_settings_json (
881
+ client_settings_json_path , client_settings_json_updates
954
882
)
883
+ with open (client_settings_json_path , "w" ) as client_settings_json_file :
884
+ client_settings_json_file .write (json .dumps (client_settings_json ))
955
885
956
- validate_log_viewer_webui_config (clp_config , settings_json_path )
957
-
958
- # Read, update, and write back settings.json
959
- settings_json_updates = {
886
+ server_settings_json_updates = {
960
887
"SqlDbHost" : clp_config .database .host ,
961
888
"SqlDbPort" : clp_config .database .port ,
962
889
"SqlDbName" : clp_config .database .name ,
963
890
"SqlDbQueryJobsTableName" : QUERY_JOBS_TABLE_NAME ,
964
891
"MongoDbHost" : clp_config .results_cache .host ,
965
892
"MongoDbPort" : clp_config .results_cache .port ,
966
893
"MongoDbName" : clp_config .results_cache .db_name ,
894
+ "MongoDbSearchResultsMetadataCollectionName" : clp_config .webui .results_metadata_collection_name ,
967
895
"MongoDbStreamFilesCollectionName" : clp_config .results_cache .stream_collection_name ,
968
- "ClientDir" : str (container_log_viewer_webui_dir / "client" ),
896
+ "ClientDir" : str (container_webui_dir / "client" ),
897
+ "LogViewerDir" : str (container_webui_dir / "yscope-log-viewer" ),
969
898
"StreamFilesDir" : str (container_clp_config .stream_output .get_directory ()),
970
899
"StreamTargetUncompressedSize" : container_clp_config .stream_output .target_uncompressed_size ,
971
- "LogViewerDir" : str (container_log_viewer_webui_dir / "yscope-log-viewer" ),
972
900
}
973
901
974
902
container_cmd_extra_opts = []
@@ -977,23 +905,25 @@ def start_log_viewer_webui(
977
905
if StorageType .S3 == stream_storage .type :
978
906
s3_config = stream_storage .s3_config
979
907
980
- settings_json_updates ["StreamFilesS3Region" ] = s3_config .region_code
981
- settings_json_updates ["StreamFilesS3PathPrefix" ] = (
908
+ server_settings_json_updates ["StreamFilesS3Region" ] = s3_config .region_code
909
+ server_settings_json_updates ["StreamFilesS3PathPrefix" ] = (
982
910
f"{ s3_config .bucket } /{ s3_config .key_prefix } "
983
911
)
984
912
auth = s3_config .aws_authentication
985
913
if AwsAuthType .profile == auth .type :
986
- settings_json_updates ["StreamFilesS3Profile" ] = auth .profile
914
+ server_settings_json_updates ["StreamFilesS3Profile" ] = auth .profile
987
915
else :
988
- settings_json_updates ["StreamFilesS3Profile" ] = None
916
+ server_settings_json_updates ["StreamFilesS3Profile" ] = None
989
917
elif StorageType .FS == stream_storage .type :
990
- settings_json_updates ["StreamFilesS3Region" ] = None
991
- settings_json_updates ["StreamFilesS3PathPrefix" ] = None
992
- settings_json_updates ["StreamFilesS3Profile" ] = None
918
+ server_settings_json_updates ["StreamFilesS3Region" ] = None
919
+ server_settings_json_updates ["StreamFilesS3PathPrefix" ] = None
920
+ server_settings_json_updates ["StreamFilesS3Profile" ] = None
993
921
994
- settings_json = read_and_update_settings_json (settings_json_path , settings_json_updates )
995
- with open (settings_json_path , "w" ) as settings_json_file :
996
- settings_json_file .write (json .dumps (settings_json ))
922
+ server_settings_json = read_and_update_settings_json (
923
+ server_settings_json_path , server_settings_json_updates
924
+ )
925
+ with open (server_settings_json_path , "w" ) as settings_json_file :
926
+ settings_json_file .write (json .dumps (server_settings_json ))
997
927
998
928
# fmt: off
999
929
container_cmd = [
@@ -1009,8 +939,8 @@ def start_log_viewer_webui(
1009
939
1010
940
necessary_env_vars = [
1011
941
f"NODE_PATH={ node_path } " ,
1012
- f"HOST={ clp_config .log_viewer_webui .host } " ,
1013
- f"PORT={ clp_config .log_viewer_webui .port } " ,
942
+ f"HOST={ clp_config .webui .host } " ,
943
+ f"PORT={ clp_config .webui .port } " ,
1014
944
f"CLP_DB_USER={ clp_config .database .username } " ,
1015
945
f"CLP_DB_PASS={ clp_config .database .password } " ,
1016
946
f"NODE_ENV=production" ,
@@ -1027,7 +957,7 @@ def start_log_viewer_webui(
1027
957
necessary_env_vars .append (f"AWS_SECRET_ACCESS_KEY={ credentials .secret_access_key } " )
1028
958
else :
1029
959
aws_mount , aws_env_vars = generate_container_auth_options (
1030
- clp_config , LOG_VIEWER_WEBUI_COMPONENT_NAME
960
+ clp_config , WEBUI_COMPONENT_NAME
1031
961
)
1032
962
if aws_mount :
1033
963
necessary_mounts .append (mounts .aws_config_dir )
@@ -1038,7 +968,7 @@ def start_log_viewer_webui(
1038
968
1039
969
node_cmd = [
1040
970
str (CONTAINER_CLP_HOME / "bin" / "node-22" ),
1041
- str (container_log_viewer_webui_dir / "server" / "dist" / "server" / "src" / "main.js" ),
971
+ str (container_webui_dir / "server" / "dist" / "server" / "src" / "main.js" ),
1042
972
]
1043
973
cmd = container_cmd + node_cmd
1044
974
subprocess .run (cmd , stdout = subprocess .DEVNULL , check = True )
@@ -1147,7 +1077,6 @@ def main(argv):
1147
1077
reducer_server_parser = component_args_parser .add_parser (REDUCER_COMPONENT_NAME )
1148
1078
add_num_workers_argument (reducer_server_parser )
1149
1079
component_args_parser .add_parser (WEBUI_COMPONENT_NAME )
1150
- component_args_parser .add_parser (LOG_VIEWER_WEBUI_COMPONENT_NAME )
1151
1080
1152
1081
parsed_args = args_parser .parse_args (argv [1 :])
1153
1082
@@ -1175,7 +1104,6 @@ def main(argv):
1175
1104
COMPRESSION_SCHEDULER_COMPONENT_NAME ,
1176
1105
QUERY_SCHEDULER_COMPONENT_NAME ,
1177
1106
WEBUI_COMPONENT_NAME ,
1178
- LOG_VIEWER_WEBUI_COMPONENT_NAME ,
1179
1107
):
1180
1108
validate_and_load_db_credentials_file (clp_config , clp_home , True )
1181
1109
if target in (
@@ -1271,9 +1199,7 @@ def main(argv):
1271
1199
if target in (ALL_TARGET_NAME , REDUCER_COMPONENT_NAME ):
1272
1200
start_reducer (instance_id , clp_config , container_clp_config , num_workers , mounts )
1273
1201
if target in (ALL_TARGET_NAME , WEBUI_COMPONENT_NAME ):
1274
- start_webui (instance_id , clp_config , mounts )
1275
- if target in (ALL_TARGET_NAME , LOG_VIEWER_WEBUI_COMPONENT_NAME ):
1276
- start_log_viewer_webui (instance_id , clp_config , container_clp_config , mounts )
1202
+ start_webui (instance_id , clp_config , container_clp_config , mounts )
1277
1203
1278
1204
except Exception as ex :
1279
1205
if type (ex ) == ValueError :
0 commit comments