diff --git a/src/apache/apache_launcher.star b/src/apache/apache_launcher.star index e69ffe3af..9f25b6a13 100644 --- a/src/apache/apache_launcher.star +++ b/src/apache/apache_launcher.star @@ -6,8 +6,9 @@ HTTP_PORT_ID = "http" HTTP_PORT_NUMBER = 80 APACHE_CONFIG_FILENAME = "index.html" -APACHE_ENR_FILENAME = "boot_enr.txt" +APACHE_ENR_FILENAME = "boot_enr.yaml" APACHE_ENODE_FILENAME = "bootnode.txt" +APACHE_ENR_LIST_FILENAME = "bootstrap_nodes.txt" APACHE_CONFIG_MOUNT_DIRPATH_ON_SERVICE = "/usr/local/apache2/htdocs/" @@ -37,29 +38,43 @@ def launch_apache( src=static_files.APACHE_CONFIG_FILEPATH, name="apache-config" ) - all_enrs=[] - all_enodes=[] + all_cl_client_info = [] + all_el_client_info = [] for index, participant in enumerate(participant_contexts): _, cl_client, el_client, _ = shared_utils.get_client_names( participant, index, participant_contexts, participant_configs ) - all_enrs.append(cl_client.enr) - all_enodes.append(el_client.enode) - + all_cl_client_info.append(new_cl_client_info(cl_client.enr)) + all_el_client_info.append(new_el_client_info(el_client.enode)) template_data = new_config_template_data( - all_enrs, - all_enodes, + all_cl_client_info, + all_el_client_info, + ) + + enr_template_and_data = shared_utils.new_template_and_data( + read_file(static_files.APACHE_ENR_FILEPATH), + template_data, ) - template_and_data = shared_utils.new_template_and_data( - static_files.APACHE_ENR_FILEPATH, + enr_list_template_and_data = shared_utils.new_template_and_data( + read_file(static_files.APACHE_ENR_LIST_FILEPATH), + template_data, + ) + + enode_template_and_data = shared_utils.new_template_and_data( + read_file(static_files.APACHE_ENODE_FILEPATH), template_data, ) template_and_data_by_rel_dest_filepath = {} - template_and_data_by_rel_dest_filepath[APACHE_ENR_FILENAME] = template_and_data - template_and_data_by_rel_dest_filepath[APACHE_ENODE_FILENAME] = template_and_data + template_and_data_by_rel_dest_filepath[APACHE_ENR_FILENAME] = enr_template_and_data + template_and_data_by_rel_dest_filepath[ + APACHE_ENR_LIST_FILENAME + ] = enr_list_template_and_data + template_and_data_by_rel_dest_filepath[ + APACHE_ENODE_FILENAME + ] = enode_template_and_data bootstrap_info_files_artifact_name = plan.render_templates( template_and_data_by_rel_dest_filepath, "bootstrap-info" @@ -83,25 +98,36 @@ def get_config( ): files = { constants.GENESIS_DATA_MOUNTPOINT_ON_CLIENTS: el_cl_genesis_data, - constants.GENESIS_DATA_MOUNTPOINT_ON_CLIENTS + "/boot": bootstrap_info_files_artifact_name, + constants.GENESIS_DATA_MOUNTPOINT_ON_CLIENTS + + "/boot": bootstrap_info_files_artifact_name, APACHE_CONFIG_MOUNT_DIRPATH_ON_SERVICE: config_files_artifact_name, } cmd = [ - # "echo", - # "AddType application/octet-stream .tar", - # ">>", - # "/usr/local/apache2/conf/httpd.conf", - # "&&", - # "cat < /network-configs/enodes.txt\n" + enode_list + "\nEOT", - # "&&", - # "tar", - # "-czvf", - # "/usr/local/apache2/htdocs/network-config.tar", - # "-C", - # "/network-configs/", - # ".", - # "&&", + "echo", + "AddType application/octet-stream .tar", + ">>", + "/usr/local/apache2/conf/httpd.conf", + "&&", + "mv", + "/network-configs/boot/" + APACHE_ENR_FILENAME, + "/network-configs/" + APACHE_ENR_FILENAME, + "&&", + "mv", + "/network-configs/boot/" + APACHE_ENODE_FILENAME, + "/network-configs/" + APACHE_ENODE_FILENAME, + "&&", + "mv", + "/network-configs/boot/" + APACHE_ENR_LIST_FILENAME, + "/network-configs/" + APACHE_ENR_LIST_FILENAME, + "&&", + "tar", + "-czvf", + "/usr/local/apache2/htdocs/network-config.tar", + "-C", + "/network-configs/", + ".", + "&&", "httpd-foreground", ] @@ -120,8 +146,21 @@ def get_config( node_selectors=node_selectors, ) -def new_config_template_data(cl_client_info, el_client_info): + +def new_config_template_data(cl_client, el_client): + return { + "CLClient": cl_client, + "ELClient": el_client, + } + + +def new_cl_client_info(enr): + return { + "Enr": enr, + } + + +def new_el_client_info(enode): return { - "CLClientInfo": cl_client_info, - "ELClientInfo": el_client_info, + "Enode": enode, } diff --git a/src/static_files/static_files.star b/src/static_files/static_files.star index 978a34a91..08b1ecd85 100644 --- a/src/static_files/static_files.star +++ b/src/static_files/static_files.star @@ -18,6 +18,7 @@ VALIDATOR_RANGES_CONFIG_TEMPLATE_FILEPATH = ( APACHE_CONFIG_FILEPATH = STATIC_FILES_DIRPATH + "/apache-config/index.html" APACHE_ENR_FILEPATH = STATIC_FILES_DIRPATH + "/apache-config/enr.txt.tmpl" +APACHE_ENR_LIST_FILEPATH = STATIC_FILES_DIRPATH + "/apache-config/enr_list.txt.tmpl" APACHE_ENODE_FILEPATH = STATIC_FILES_DIRPATH + "/apache-config/enode.txt.tmpl" DORA_CONFIG_TEMPLATE_FILEPATH = STATIC_FILES_DIRPATH + "/dora-config/config.yaml.tmpl" diff --git a/static_files/apache-config/enode.txt.tmpl b/static_files/apache-config/enode.txt.tmpl index 2fb1c6706..62889f4f6 100644 --- a/static_files/apache-config/enode.txt.tmpl +++ b/static_files/apache-config/enode.txt.tmpl @@ -1,3 +1,3 @@ -{{ range $elClient := .ELClientInfo }} -{{ .elClient.enode }} +{{ range $elClient := .ELClient }} +{{ $elClient.Enode }} {{- end }} diff --git a/static_files/apache-config/enr.txt.tmpl b/static_files/apache-config/enr.txt.tmpl index 02d7824e4..7d5a60053 100644 --- a/static_files/apache-config/enr.txt.tmpl +++ b/static_files/apache-config/enr.txt.tmpl @@ -1,3 +1,3 @@ -{{ range $clClient := .CLClientInfo }} -- {{ .clClient.enr }} +{{ range $clClient := .CLClient }} +- {{ $clClient.Enr }} {{- end }} diff --git a/static_files/apache-config/enr_list.txt.tmpl b/static_files/apache-config/enr_list.txt.tmpl new file mode 100644 index 000000000..15345a762 --- /dev/null +++ b/static_files/apache-config/enr_list.txt.tmpl @@ -0,0 +1,3 @@ +{{ range $clClient := .CLClient }} +{{ $clClient.Enr }} +{{- end }}