kopia lustrzana https://github.com/bugout-dev/moonstream
Nodebalancer deployment fix to work as user
rodzic
5949ddf3eb
commit
3ba9c8927a
|
@ -24,11 +24,10 @@ PARAMETERS_ENV_PATH="${SECRETS_DIR}/app.env"
|
||||||
AWS_SSM_PARAMETER_PATH="${AWS_SSM_PARAMETER_PATH:-/moonstream/prod}"
|
AWS_SSM_PARAMETER_PATH="${AWS_SSM_PARAMETER_PATH:-/moonstream/prod}"
|
||||||
SCRIPT_DIR="$(realpath $(dirname $0))"
|
SCRIPT_DIR="$(realpath $(dirname $0))"
|
||||||
PARAMETERS_SCRIPT="${SCRIPT_DIR}/parameters.py"
|
PARAMETERS_SCRIPT="${SCRIPT_DIR}/parameters.py"
|
||||||
NODE_BALANCER_CONFIG_PATH="${NODE_BALANCER_CONFIG_PATH:-/home/ubuntu/.nodebalancer}"
|
NODE_BALANCER_CONFIG_PATH="${NODE_BALANCER_CONFIG_PATH:-/home/ubuntu/.nodebalancer/config.json}"
|
||||||
NODE_BALANCER_CONFIG_SOURCE_FILE="node-balancer-config.txt"
|
|
||||||
|
|
||||||
# Service file
|
# Service file
|
||||||
NODE_BALANCER_SERVICE_FILE="node-balancer.service"
|
NODE_BALANCER_SERVICE_FILE="nodebalancer.service"
|
||||||
|
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
|
@ -41,12 +40,12 @@ AWS_DEFAULT_REGION="${AWS_DEFAULT_REGION}" "${PYTHON}" "${PARAMETERS_SCRIPT}" ex
|
||||||
echo
|
echo
|
||||||
echo
|
echo
|
||||||
echo -e "${PREFIX_INFO} Install checkenv"
|
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
|
echo
|
||||||
echo -e "${PREFIX_INFO} Retrieving addition deployment parameters"
|
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
|
||||||
echo
|
echo
|
||||||
|
@ -58,22 +57,21 @@ echo
|
||||||
echo -e "${PREFIX_INFO} Building executable load balancer for nodes script with Go"
|
echo -e "${PREFIX_INFO} Building executable load balancer for nodes script with Go"
|
||||||
EXEC_DIR=$(pwd)
|
EXEC_DIR=$(pwd)
|
||||||
cd "${APP_NODES_DIR}/node_balancer"
|
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}"
|
cd "${EXEC_DIR}"
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo
|
echo
|
||||||
echo -e "${PREFIX_INFO} Update nodebalancer configuration file"
|
echo -e "${PREFIX_INFO} Update nodebalancer configuration file"
|
||||||
if [ ! -d "$NODE_BALANCER_CONFIG_PATH" ]; then
|
if [ ! -z "$NODE_BALANCER_CONFIG_PATH" ]; then
|
||||||
mkdir "$NODE_BALANCER_CONFIG_PATH"
|
echo -e "${PREFIX_CRIT} Node balancer configuration not found"
|
||||||
echo -e "${PREFIX_WARN} Created new node balancer config directory"
|
exit 1
|
||||||
fi
|
fi
|
||||||
cp "${SCRIPT_DIR}/${NODE_BALANCER_CONFIG_SOURCE_FILE}" "${NODE_BALANCER_CONFIG_PATH}/config.txt"
|
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo
|
echo
|
||||||
echo -e "${PREFIX_INFO} Replacing existing load balancer for nodes service definition with ${NODE_BALANCER_SERVICE_FILE}"
|
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}"
|
chmod 644 "${SCRIPT_DIR}/${NODE_BALANCER_SERVICE_FILE}"
|
||||||
cp "${SCRIPT_DIR}/${NODE_BALANCER_SERVICE_FILE}" "/etc/systemd/system/${NODE_BALANCER_SERVICE_FILE}"
|
cp "${SCRIPT_DIR}/${NODE_BALANCER_SERVICE_FILE}" "/home/ubuntu/.config/systemd/user/${NODE_BALANCER_SERVICE_FILE}"
|
||||||
systemctl daemon-reload
|
systemctl --user daemon-reload
|
||||||
systemctl restart "${NODE_BALANCER_SERVICE_FILE}"
|
systemctl --user restart "${NODE_BALANCER_SERVICE_FILE}"
|
||||||
|
|
|
@ -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
|
|
|
@ -6,7 +6,7 @@ StartLimitBurst=3
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
User=ubuntu
|
User=ubuntu
|
||||||
Group=www-data
|
Group=ubuntu
|
||||||
WorkingDirectory=/home/ubuntu/moonstream/nodes/node_balancer
|
WorkingDirectory=/home/ubuntu/moonstream/nodes/node_balancer
|
||||||
EnvironmentFile=/home/ubuntu/moonstream-secrets/app.env
|
EnvironmentFile=/home/ubuntu/moonstream-secrets/app.env
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
|
@ -16,7 +16,7 @@ ExecStart=/home/ubuntu/moonstream/nodes/node_balancer/nodebalancer server \
|
||||||
-port 8544 \
|
-port 8544 \
|
||||||
-healthcheck \
|
-healthcheck \
|
||||||
-config /home/ubuntu/.nodebalancer/config.json
|
-config /home/ubuntu/.nodebalancer/config.json
|
||||||
SyslogIdentifier=node-balancer
|
SyslogIdentifier=nodebalancer
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
Ładowanie…
Reference in New Issue