mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-14 17:02:56 +00:00
this is safe because unknown fields are ignored. After the corresponding PR in control plane is merged this field is going to be required Part of https://github.com/neondatabase/cloud/issues/3131
34 lines
1.1 KiB
Bash
34 lines
1.1 KiB
Bash
#!/bin/sh
|
|
|
|
# fetch params from meta-data service
|
|
INSTANCE_ID=$(curl -s http://169.254.169.254/latest/meta-data/instance-id)
|
|
AZ_ID=$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone)
|
|
|
|
# store fqdn hostname in var
|
|
HOST=$(hostname -f)
|
|
|
|
|
|
cat <<EOF | tee /tmp/payload
|
|
{
|
|
"version": 1,
|
|
"host": "${HOST}",
|
|
"port": 6400,
|
|
"region_id": "{{ console_region_id }}",
|
|
"instance_id": "${INSTANCE_ID}",
|
|
"http_host": "${HOST}",
|
|
"http_port": 9898,
|
|
"active": false,
|
|
"availability_zone_id": "${AZ_ID}"
|
|
}
|
|
EOF
|
|
|
|
# check if pageserver already registered or not
|
|
if ! curl -sf -H "Authorization: Bearer {{ CONSOLE_API_TOKEN }}" {{ console_mgmt_base_url }}/management/api/v2/pageservers/${INSTANCE_ID} -o /dev/null; then
|
|
|
|
# not registered, so register it now
|
|
ID=$(curl -sf -X POST -H "Authorization: Bearer {{ CONSOLE_API_TOKEN }}" {{ console_mgmt_base_url }}/management/api/v2/pageservers -d@/tmp/payload | jq -r '.id')
|
|
|
|
# init pageserver
|
|
sudo -u pageserver /usr/local/bin/pageserver -c "id=${ID}" -c "pg_distrib_dir='/usr/local'" --init -D /storage/pageserver/data
|
|
fi
|