Nodebalancer deployment fix to work as user

pull/637/head
kompotkot 2022-07-14 14:15:01 +00:00
rodzic 5949ddf3eb
commit 3ba9c8927a
3 zmienionych plików z 14 dodań i 21 usunięć

Wyświetl plik

@ -24,11 +24,10 @@ PARAMETERS_ENV_PATH="${SECRETS_DIR}/app.env"
AWS_SSM_PARAMETER_PATH="${AWS_SSM_PARAMETER_PATH:-/moonstream/prod}"
SCRIPT_DIR="$(realpath $(dirname $0))"
PARAMETERS_SCRIPT="${SCRIPT_DIR}/parameters.py"
NODE_BALANCER_CONFIG_PATH="${NODE_BALANCER_CONFIG_PATH:-/home/ubuntu/.nodebalancer}"
NODE_BALANCER_CONFIG_SOURCE_FILE="node-balancer-config.txt"
NODE_BALANCER_CONFIG_PATH="${NODE_BALANCER_CONFIG_PATH:-/home/ubuntu/.nodebalancer/config.json}"
# Service file
NODE_BALANCER_SERVICE_FILE="node-balancer.service"
NODE_BALANCER_SERVICE_FILE="nodebalancer.service"
set -eu
@ -41,12 +40,12 @@ AWS_DEFAULT_REGION="${AWS_DEFAULT_REGION}" "${PYTHON}" "${PARAMETERS_SCRIPT}" ex
echo
echo
echo -e "${PREFIX_INFO} Install checkenv"
HOME=/root /usr/local/go/bin/go install github.com/bugout-dev/checkenv@latest
HOME=/home/ubuntu /usr/local/go/bin/go install github.com/bugout-dev/checkenv@latest
echo
echo
echo -e "${PREFIX_INFO} Retrieving addition deployment parameters"
AWS_DEFAULT_REGION="${AWS_DEFAULT_REGION}" /root/go/bin/checkenv show aws_ssm+Product:moonstream >> "${PARAMETERS_ENV_PATH}"
AWS_DEFAULT_REGION="${AWS_DEFAULT_REGION}" /home/ubuntu/go/bin/checkenv show aws_ssm+Product:moonstream >> "${PARAMETERS_ENV_PATH}"
echo
echo
@ -58,22 +57,21 @@ echo
echo -e "${PREFIX_INFO} Building executable load balancer for nodes script with Go"
EXEC_DIR=$(pwd)
cd "${APP_NODES_DIR}/node_balancer"
HOME=/root /usr/local/go/bin/go build -o "${APP_NODES_DIR}/node_balancer/nodebalancer" "${APP_NODES_DIR}/node_balancer/cmd/nodebalancer/*.go"
HOME=/home/ubuntu /usr/local/go/bin/go build -o "${APP_NODES_DIR}/node_balancer/nodebalancer" "${APP_NODES_DIR}/node_balancer/cmd/nodebalancer/*.go"
cd "${EXEC_DIR}"
echo
echo
echo -e "${PREFIX_INFO} Update nodebalancer configuration file"
if [ ! -d "$NODE_BALANCER_CONFIG_PATH" ]; then
mkdir "$NODE_BALANCER_CONFIG_PATH"
echo -e "${PREFIX_WARN} Created new node balancer config directory"
if [ ! -z "$NODE_BALANCER_CONFIG_PATH" ]; then
echo -e "${PREFIX_CRIT} Node balancer configuration not found"
exit 1
fi
cp "${SCRIPT_DIR}/${NODE_BALANCER_CONFIG_SOURCE_FILE}" "${NODE_BALANCER_CONFIG_PATH}/config.txt"
echo
echo
echo -e "${PREFIX_INFO} Replacing existing load balancer for nodes service definition with ${NODE_BALANCER_SERVICE_FILE}"
chmod 644 "${SCRIPT_DIR}/${NODE_BALANCER_SERVICE_FILE}"
cp "${SCRIPT_DIR}/${NODE_BALANCER_SERVICE_FILE}" "/etc/systemd/system/${NODE_BALANCER_SERVICE_FILE}"
systemctl daemon-reload
systemctl restart "${NODE_BALANCER_SERVICE_FILE}"
cp "${SCRIPT_DIR}/${NODE_BALANCER_SERVICE_FILE}" "/home/ubuntu/.config/systemd/user/${NODE_BALANCER_SERVICE_FILE}"
systemctl --user daemon-reload
systemctl --user restart "${NODE_BALANCER_SERVICE_FILE}"

Wyświetl plik

@ -1,5 +0,0 @@
ethereum,a.ethereum.moonstream.internal,8545
ethereum,b.ethereum.moonstream.internal,8545
polygon,a.polygon.moonstream.internal,8545
polygon,b.polygon.moonstream.internal,8545
xdai,a.xdai.moonstream.internal,8545

Wyświetl plik

@ -6,7 +6,7 @@ StartLimitBurst=3
[Service]
User=ubuntu
Group=www-data
Group=ubuntu
WorkingDirectory=/home/ubuntu/moonstream/nodes/node_balancer
EnvironmentFile=/home/ubuntu/moonstream-secrets/app.env
Restart=on-failure
@ -16,7 +16,7 @@ ExecStart=/home/ubuntu/moonstream/nodes/node_balancer/nodebalancer server \
-port 8544 \
-healthcheck \
-config /home/ubuntu/.nodebalancer/config.json
SyslogIdentifier=node-balancer
SyslogIdentifier=nodebalancer
[Install]
WantedBy=multi-user.target
WantedBy=multi-user.target