Skip to content

Commit

Permalink
add all bootnode files
Browse files Browse the repository at this point in the history
  • Loading branch information
barnabasbusa committed May 6, 2024
1 parent 84b9e2c commit 66ad563
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 34 deletions.
99 changes: 69 additions & 30 deletions src/apache/apache_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -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/"

Expand Down Expand Up @@ -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"
Expand All @@ -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 <<EOT > /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",
]

Expand All @@ -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,
}
1 change: 1 addition & 0 deletions src/static_files/static_files.star
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions static_files/apache-config/enode.txt.tmpl
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{{ range $elClient := .ELClientInfo }}
{{ .elClient.enode }}
{{ range $elClient := .ELClient }}
{{ $elClient.Enode }}
{{- end }}
4 changes: 2 additions & 2 deletions static_files/apache-config/enr.txt.tmpl
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{{ range $clClient := .CLClientInfo }}
- {{ .clClient.enr }}
{{ range $clClient := .CLClient }}
- {{ $clClient.Enr }}
{{- end }}
3 changes: 3 additions & 0 deletions static_files/apache-config/enr_list.txt.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{ range $clClient := .CLClient }}
{{ $clClient.Enr }}
{{- end }}

0 comments on commit 66ad563

Please sign in to comment.