Skip to content
This repository has been archived by the owner on Mar 18, 2024. It is now read-only.

Commit

Permalink
fix: installation bug
Browse files Browse the repository at this point in the history
  • Loading branch information
carlocorradini committed Nov 30, 2022
1 parent 712d081 commit 68a8b0b
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 372 deletions.
2 changes: 1 addition & 1 deletion configs/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ kind: controller
# kind: server

recluster:
server: http://192.168.0.10:8080
server: http://127.0.0.1:8080 # TODO Change

ssh_authorized_keys:
- ssh-ed25519 ... # TODO Change with SSH public key !
2 changes: 1 addition & 1 deletion configs/k3s.worker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
# SOFTWARE.

token: 4646f99bc4cbae3d5eceed856b337c9d3284be0d4056a3909f780c0c385fbf93
server: https://192.168.0.10:6443
server: https://127.0.0.1:6443 # TODO Change
4 changes: 2 additions & 2 deletions configs/server.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
# NODE
# ================
# Node environment
# NODE_ENV="development"
NODE_ENV="production"

# ================
# SERVER
# ================
# Server host
# HOST="0.0.0.0"
# Server port
# PORT=8080
PORT=8080

# ================
# LOGGER
Expand Down
25 changes: 21 additions & 4 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -846,8 +846,8 @@ node_registration() {
curl --fail --silent --location --show-error \
--request POST \
--header 'Content-Type: application/json' \
--url "$_server_url" \
--data "$_request_data"
--data "$_request_data" \
--url "$_server_url"
) || FATAL "Error sending node registration request to '$_server_url'"
;;
wget)
Expand Down Expand Up @@ -1571,6 +1571,9 @@ cluster_init() {
_server_env_file="$RECLUSTER_ETC_DIR/server.env"
_server_certs_dir="$RECLUSTER_ETC_DIR/certs"
_server_dir="$RECLUSTER_OPT_DIR/server"
_wait_server_max_attempts=3
_wait_server_sleep=3
_server_url=$(printf '%s\n' "$CONFIG" | jq --exit-status --raw-output '.recluster.server')

_wait_k3s_kubeconfig_file_creation() {
_k3s_kubeconfig_dir=$(dirname "$_k3s_kubeconfig_file")
Expand Down Expand Up @@ -1677,7 +1680,7 @@ depend() {
supervisor=supervise-daemon
name=recluster.server
command=/usr/bin/node $_server_dir/build/main.js
command="/usr/bin/node $_server_dir/build/main.js"
output_log=$_openrc_server_log_file
output_log=$_openrc_server_log_file
Expand Down Expand Up @@ -1747,6 +1750,20 @@ EOF
;;
*) FATAL "Unknown init system '$INIT_SYSTEM'" ;;
esac

# Wait server
INFO "Waiting server reachability"
while [ "$_wait_server_max_attempts" -gt 0 ]; do
if (assert_url_reachability "$_server_url/health" > /dev/null 2>&1); then
DEBUG "Server is reachable"
break
fi

DEBUG "Server is not reachable, sleeping $_wait_server_sleep"
sleep "$_wait_server_sleep"
_wait_server_max_attempts=$((_wait_server_max_attempts = _wait_server_max_attempts - 1))
done
[ "$_wait_server_max_attempts" -gt 0 ] || FATAL "Server is not reachable, maximum attempts reached"
}

# Install reCluster
Expand Down Expand Up @@ -1776,7 +1793,7 @@ install_recluster() {
| yq e --no-colors '(.. | select(tag == "!!str")) style="double"' - \
| $SUDO tee "$_recluster_config_file" > /dev/null
$SUDO chown root:root "$_recluster_config_file"
$SUDO chmod 644 "$_recluster_config_file"
$SUDO chmod 600 "$_recluster_config_file"

# Register node
node_registration
Expand Down
4 changes: 2 additions & 2 deletions server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ reCluster server.
1. Execute Queries

- Apollo Studio \
Visit <http://localhost:8080> in your browser
Visit <http://localhost:8080/graphql> in your browser

- Manually

```sh
curl --request POST \
--header 'content-type: application/json' \
--url 'http://localhost:8080' \
--url 'http://localhost:8080/graphql' \
--data '{ "query": "query { __typename }" }'
```

Expand Down
Loading

0 comments on commit 68a8b0b

Please sign in to comment.