2424 CONTROLLER_TARGET_NAME ,
2525 DB_COMPONENT_NAME ,
2626 FILES_TABLE_SUFFIX ,
27- LOG_VIEWER_WEBUI_COMPONENT_NAME ,
2827 QUERY_JOBS_TABLE_NAME ,
2928 QUERY_SCHEDULER_COMPONENT_NAME ,
3029 QUERY_WORKER_COMPONENT_NAME ,
5756 validate_and_load_queue_credentials_file ,
5857 validate_and_load_redis_credentials_file ,
5958 validate_db_config ,
60- validate_log_viewer_webui_config ,
6159 validate_queue_config ,
6260 validate_redis_config ,
6361 validate_reducer_config ,
@@ -843,132 +841,62 @@ def read_and_update_settings_json(settings_file_path: pathlib.Path, updates: Dic
843841 return settings_object
844842
845843
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+ ):
847850 component_name = WEBUI_COMPONENT_NAME
848851 logger .info (f"Starting { component_name } ..." )
849852
850853 container_name = f"clp-{ component_name } -{ instance_id } "
851854 if container_exists (container_name ):
852855 return
853856
854- webui_logs_dir = clp_config .logs_directory / component_name
855857 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+ )
863865
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 )
865867
866- # Read and update settings.json
868+ # Read, update, and write back client's and server's settings.json
867869 clp_db_connection_params = clp_config .database .get_clp_connection_params_and_type (True )
868870 table_prefix = clp_db_connection_params ["table_prefix" ]
869871 if StorageEngine .CLP_S == clp_config .package .storage_engine :
870872 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 ,
887879 }
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
954882 )
883+ with open (client_settings_json_path , "w" ) as client_settings_json_file :
884+ client_settings_json_file .write (json .dumps (client_settings_json ))
955885
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 = {
960887 "SqlDbHost" : clp_config .database .host ,
961888 "SqlDbPort" : clp_config .database .port ,
962889 "SqlDbName" : clp_config .database .name ,
963890 "SqlDbQueryJobsTableName" : QUERY_JOBS_TABLE_NAME ,
964891 "MongoDbHost" : clp_config .results_cache .host ,
965892 "MongoDbPort" : clp_config .results_cache .port ,
966893 "MongoDbName" : clp_config .results_cache .db_name ,
894+ "MongoDbSearchResultsMetadataCollectionName" : clp_config .webui .results_metadata_collection_name ,
967895 "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" ),
969898 "StreamFilesDir" : str (container_clp_config .stream_output .get_directory ()),
970899 "StreamTargetUncompressedSize" : container_clp_config .stream_output .target_uncompressed_size ,
971- "LogViewerDir" : str (container_log_viewer_webui_dir / "yscope-log-viewer" ),
972900 }
973901
974902 container_cmd_extra_opts = []
@@ -977,23 +905,25 @@ def start_log_viewer_webui(
977905 if StorageType .S3 == stream_storage .type :
978906 s3_config = stream_storage .s3_config
979907
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" ] = (
982910 f"{ s3_config .bucket } /{ s3_config .key_prefix } "
983911 )
984912 auth = s3_config .aws_authentication
985913 if AwsAuthType .profile == auth .type :
986- settings_json_updates ["StreamFilesS3Profile" ] = auth .profile
914+ server_settings_json_updates ["StreamFilesS3Profile" ] = auth .profile
987915 else :
988- settings_json_updates ["StreamFilesS3Profile" ] = None
916+ server_settings_json_updates ["StreamFilesS3Profile" ] = None
989917 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
993921
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 ))
997927
998928 # fmt: off
999929 container_cmd = [
@@ -1009,8 +939,8 @@ def start_log_viewer_webui(
1009939
1010940 necessary_env_vars = [
1011941 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 } " ,
1014944 f"CLP_DB_USER={ clp_config .database .username } " ,
1015945 f"CLP_DB_PASS={ clp_config .database .password } " ,
1016946 f"NODE_ENV=production" ,
@@ -1027,7 +957,7 @@ def start_log_viewer_webui(
1027957 necessary_env_vars .append (f"AWS_SECRET_ACCESS_KEY={ credentials .secret_access_key } " )
1028958 else :
1029959 aws_mount , aws_env_vars = generate_container_auth_options (
1030- clp_config , LOG_VIEWER_WEBUI_COMPONENT_NAME
960+ clp_config , WEBUI_COMPONENT_NAME
1031961 )
1032962 if aws_mount :
1033963 necessary_mounts .append (mounts .aws_config_dir )
@@ -1038,7 +968,7 @@ def start_log_viewer_webui(
1038968
1039969 node_cmd = [
1040970 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" ),
1042972 ]
1043973 cmd = container_cmd + node_cmd
1044974 subprocess .run (cmd , stdout = subprocess .DEVNULL , check = True )
@@ -1147,7 +1077,6 @@ def main(argv):
11471077 reducer_server_parser = component_args_parser .add_parser (REDUCER_COMPONENT_NAME )
11481078 add_num_workers_argument (reducer_server_parser )
11491079 component_args_parser .add_parser (WEBUI_COMPONENT_NAME )
1150- component_args_parser .add_parser (LOG_VIEWER_WEBUI_COMPONENT_NAME )
11511080
11521081 parsed_args = args_parser .parse_args (argv [1 :])
11531082
@@ -1175,7 +1104,6 @@ def main(argv):
11751104 COMPRESSION_SCHEDULER_COMPONENT_NAME ,
11761105 QUERY_SCHEDULER_COMPONENT_NAME ,
11771106 WEBUI_COMPONENT_NAME ,
1178- LOG_VIEWER_WEBUI_COMPONENT_NAME ,
11791107 ):
11801108 validate_and_load_db_credentials_file (clp_config , clp_home , True )
11811109 if target in (
@@ -1271,9 +1199,7 @@ def main(argv):
12711199 if target in (ALL_TARGET_NAME , REDUCER_COMPONENT_NAME ):
12721200 start_reducer (instance_id , clp_config , container_clp_config , num_workers , mounts )
12731201 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 )
12771203
12781204 except Exception as ex :
12791205 if type (ex ) == ValueError :
0 commit comments