Skip to content

Commit 97ebdc1

Browse files
Merge pull request #13 from eclipsevortex/release/1.0.0
release 1.0.0
2 parents 0b3ff72 + 14816f6 commit 97ebdc1

24 files changed

Lines changed: 3583 additions & 86 deletions

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.0.7
1+
1.0.0

redis.conf

Lines changed: 2326 additions & 0 deletions
Large diffs are not rendered by default.

scripts/auto_upgrader/auto_upgrader_setup.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
set -e
44

5+
# Determine script directory dynamically
6+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7+
cd "$SCRIPT_DIR/../.."
8+
59
# Help function
610
show_help() {
711
echo "Usage: $0 [--execution=process|container|service]"

scripts/auto_upgrader/auto_upgrader_start.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
set -e
44

5+
# Determine script directory dynamically
6+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7+
cd "$SCRIPT_DIR/../.."
8+
59
# Help function
610
show_help() {
711
echo "Usage: $0 [--execution=process|container|service]"

scripts/auto_upgrader/auto_upgrader_stop.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
set -e
44

5+
# Determine script directory dynamically
6+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7+
cd "$SCRIPT_DIR/../.."
8+
59
# Help function
610
show_help() {
711
echo "Usage: $0 [--execution=process|container|service]"

scripts/auto_upgrader/auto_upgrader_teardown.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
set -e
44

5+
# Determine script directory dynamically
6+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7+
cd "$SCRIPT_DIR/../.."
8+
59
# Help function
610
show_help() {
711
echo "Usage: $0 [--execution=process|container|service]"

scripts/auto_upgrader/auto_upgrader_upgrade.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
set -e
44

5+
# Determine script directory dynamically
6+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7+
cd "$SCRIPT_DIR/../.."
8+
59
# Help function
610
show_help() {
711
echo "Usage: $0 [--execution=process|container|service --branch=<BRANCH> --tag=<TAG>]"

scripts/cleaner/clean_dumps.sh

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,32 @@ export $(grep -v '^#' subvortex/auto_upgrader/.env | xargs)
1212

1313
# Extract default DUMP_DIR from Redis config
1414
REDIS_CONF_PATH="./subvortex/auto_upgrader/template/template-subvortex-$SUBVORTEX_EXECUTION_ROLE-redis.conf"
15+
16+
1517
DUMP_DIR=$(grep -E '^\s*dir\s+' "$REDIS_CONF_PATH" | awk '{print $2}')
18+
DB_FILENAME=$(grep -E '^\s*dbfilename\s+' "$REDIS_CONF_PATH" | awk '{print $2}')
19+
CHECKSUM_DIR="/var/tmp/subvortex.checksums"
1620

17-
# Fallback if not found
21+
# Fallbacks if not found
1822
DUMP_DIR=${DUMP_DIR:-/var/tmp/dumps/redis}
23+
DB_FILENAME=${DB_FILENAME:-dump.rdb}
24+
25+
DUMP_PATH="$DUMP_DIR/$DB_FILENAME"
26+
27+
echo "🧹 Checking for Redis dump file: $DUMP_PATH"
28+
if [[ -f "$DUMP_PATH" ]]; then
29+
echo "🔥 Removing Redis dump file: $DUMP_PATH"
30+
sudo rm -f "$DUMP_PATH"
31+
else
32+
echo "ℹ️ Redis dump file not found: $DUMP_PATH — nothing to clean."
33+
fi
1934

20-
echo "🧹 Checking for dump directory at: $DUMP_DIR"
21-
if [[ -d "$DUMP_DIR" ]]; then
22-
echo "🔥 Removing dump directory and contents: $DUMP_DIR"
23-
sudo rm -rf "$DUMP_DIR"
35+
echo "🧹 Checking for checksum directory at: $CHECKSUM_DIR"
36+
if [[ -d "$CHECKSUM_DIR" ]]; then
37+
echo "🔥 Removing checksum directory and contents: $CHECKSUM_DIR"
38+
sudo rm -rf "$CHECKSUM_DIR"
2439
else
25-
echo "ℹ️ Dump directory not found: $DUMP_DIR — nothing to clean."
40+
echo "ℹ️ Checksum directory not found: $CHECKSUM_DIR — nothing to clean."
2641
fi
2742

28-
echo "✅ Cleanup dumps complete."
43+
echo "✅ Cleanup dumps ahd checksums complete."
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
# 🧭 Navigate to project root
6+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7+
cd "$SCRIPT_DIR/../../.."
8+
9+
source ./scripts/utils/utils.sh
10+
11+
show_help() {
12+
echo
13+
echo "Description:"
14+
echo " Setup and start the new miner and stop the old one"
15+
echo
16+
echo "Options:"
17+
echo " --execution Specify the execution method used from the auto upgrader r(default: service)"
18+
echo " --help Show this help message"
19+
exit 0
20+
}
21+
22+
OPTIONS="e:h"
23+
LONGOPTIONS="execution:,help"
24+
25+
# Set defaults from env (can be overridden by arguments)
26+
AU_EXECUTION="${SUBVORTEX_EXECUTION_METHOD:-service}"
27+
28+
# Parse arguments
29+
while [ "$#" -ge 1 ]; do
30+
case "$1" in
31+
-e |--execution)
32+
AU_EXECUTION="$2"
33+
shift 2
34+
;;
35+
-h | --help)
36+
show_help
37+
exit 0
38+
;;
39+
--)
40+
shift
41+
break
42+
;;
43+
*)
44+
echo "❌ Unrecognized option '$1'"
45+
exit 1
46+
;;
47+
esac
48+
done
49+
50+
# Check maandatory args
51+
check_required_args AU_EXECUTION
52+
53+
# Set execution methods
54+
source subvortex/auto_upgrader/.env
55+
SV_EXECUTION="${SUBVORTEX_EXECUTION_METHOD:-service}"
56+
57+
# ✅ Export SUBVORTEX_FLOATTING_FLAG if it exists (without error if not set)
58+
export SUBVORTEX_FLOATTING_FLAG="${SUBVORTEX_FLOATTING_FLAG:-}"
59+
60+
echo "🔧 Installing the Auto Upgrader in $AU_EXECUTION..."
61+
./scripts/auto_upgrader/auto_upgrader_setup.sh --execution "$AU_EXECUTION"
62+
63+
# --- STOP OLD MINER ---
64+
echo
65+
echo "🛠️ How is the old Miner currently running?"
66+
echo " 1) systemd service"
67+
echo " 2) background process (PM2)"
68+
echo " 3) Docker container"
69+
read -rp "⚙️ Enter option [1/2/3]: " val_mode
70+
71+
case "$val_mode" in
72+
1)
73+
read -rp "⚙️ Enter systemd service name: " val_svc
74+
echo "⛔ Stopping systemd service '$val_svc'..."
75+
sudo systemctl stop "$val_svc" || echo "⚠️ Failed to stop systemd service"
76+
;;
77+
2)
78+
read -rp "⚙️ Enter PM2 process name: " val_proc
79+
echo "⛔ Stopping PM2 process '$val_proc'..."
80+
pm2 stop "$val_proc" || echo "⚠️ Failed to stop PM2 process"
81+
;;
82+
3)
83+
read -rp "🐳 Enter Docker container name or ID: " val_container
84+
echo "⛔ Stopping Docker container '$val_container'..."
85+
docker stop "$val_container" || echo "⚠️ Failed to stop container"
86+
;;
87+
*)
88+
echo "⚠️ Invalid option. Skipping old miner stop."
89+
;;
90+
esac
91+
92+
# --- WAIT OLD MINER STOP ---
93+
if [[ "$val_mode" == "3" ]]; then
94+
echo "⏳ Waiting for Docker container '$val_container' to stop..."
95+
MAX_WAIT=60; WAIT_INTERVAL=2; elapsed=0
96+
while docker ps --format '{{.Names}}' | grep -q "^$val_container$"; do
97+
if [[ $elapsed -ge $MAX_WAIT ]]; then
98+
echo "⚠️ Docker container did not stop within timeout. Forcing stop"
99+
docker kill "$val_container" || echo "⚠️ Failed to kill container"
100+
break
101+
fi
102+
sleep "$WAIT_INTERVAL"
103+
elapsed=$((elapsed + WAIT_INTERVAL))
104+
done
105+
echo "✅ Docker container '$val_container' has stopped."
106+
else
107+
sleep 5
108+
fi
109+
110+
# --- START AUTO UPGRADER ---
111+
echo "🚀 Starting Auto Upgrader..."
112+
./scripts/auto_upgrader/auto_upgrader_start.sh --execution "$AU_EXECUTION"
113+
114+
# --- WAIT FOR NEW MINER ---
115+
echo "⏳ Waiting for Miner neuron to be up via '$SV_EXECUTION'..."
116+
NEURON_NAME="subvortex-miner-neuron"
117+
MAX_WAIT=300; WAIT_INTERVAL=3; elapsed=0; ready=0
118+
119+
while [[ $elapsed -lt $MAX_WAIT ]]; do
120+
case "$SV_EXECUTION" in
121+
service)
122+
systemctl is-active --quiet "$NEURON_NAME" && ready=1 && break
123+
;;
124+
process)
125+
pm2 list | grep -qE "$NEURON_NAME.*online" && ready=1 && break
126+
;;
127+
container)
128+
docker ps --format '{{.Names}}' | grep -q "^$NEURON_NAME$" && ready=1 && break
129+
;;
130+
*)
131+
echo "⚠️ Unknown execution method: $SV_EXECUTION"
132+
break
133+
;;
134+
esac
135+
echo "🕒 Waiting... ($elapsed/$MAX_WAIT)"
136+
sleep "$WAIT_INTERVAL"
137+
elapsed=$((elapsed + WAIT_INTERVAL))
138+
done
139+
140+
[[ $ready -eq 0 ]] && echo "❌ Timeout reached. Proceeding anyway."
141+
142+
143+
# --- START MINER NEURON ---
144+
echo "🚀 Starting miner neuron..."
145+
/root/subvortex/subvortex/miner/neuron/scripts/neuron_start.sh --execution "$SV_EXECUTION"
146+
147+
148+
echo "✅ Miner installed and started successfully."
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
# 🧭 Navigate to project root
6+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7+
cd "$SCRIPT_DIR/../../.."
8+
9+
source ./scripts/utils/utils.sh
10+
11+
show_help() {
12+
echo
13+
echo "Description:"
14+
echo " Stop and teardown the new miner and restart the old one"
15+
echo
16+
echo "Options:"
17+
echo " --execution Specify the execution method used from the auto upgrader r(default: service)"
18+
echo " --skip-auto-upgrader Skip stopping and tearing down the auto upgrader"
19+
echo " --help Show this help message"
20+
exit 0
21+
}
22+
23+
OPTIONS="e:ah"
24+
LONGOPTIONS="execution:,:skip-auto-upgrader,help"
25+
26+
# Set defaults from env (can be overridden by arguments)
27+
AU_EXECUTION="${SUBVORTEX_EXECUTION_METHOD:-service}"
28+
SKIP_AUTO_UPGRADER=false
29+
30+
# Parse arguments
31+
while [ "$#" -ge 1 ]; do
32+
case "$1" in
33+
-e |--execution)
34+
AU_EXECUTION="$2"
35+
shift 2
36+
;;
37+
--skip-auto-upgrader)
38+
SKIP_AUTO_UPGRADER=true
39+
shift
40+
;;
41+
-h | --help)
42+
show_help
43+
exit 0
44+
;;
45+
--)
46+
shift
47+
break
48+
;;
49+
*)
50+
echo "❌ Unrecognized option '$1'"
51+
exit 1
52+
;;
53+
esac
54+
done
55+
56+
# Check maandatory args
57+
check_required_args AU_EXECUTION
58+
59+
# Set execution methods
60+
source subvortex/auto_upgrader/.env
61+
SV_EXECUTION="${SUBVORTEX_EXECUTION_METHOD:-service}"
62+
63+
# ✅ Export SUBVORTEX_FLOATTING_FLAG if it exists (without error if not set)
64+
export SUBVORTEX_FLOATTING_FLAG="${SUBVORTEX_FLOATTING_FLAG:-}"
65+
66+
echo "🔄 Starting rollback & restore..."
67+
68+
# --- STOP AUTO UPGRADER ---
69+
echo "🛑 Stopping auto upgrader in $AU_EXECUTION..."
70+
./scripts/auto_upgrader/auto_upgrader_stop.sh --execution "$AU_EXECUTION" || echo "⚠️ Stoppping Auto Upgrader failed"
71+
72+
# --- TEARDOWN NEW MINER ---
73+
echo "🧨 Tearing down new miner neuron..."
74+
NEURON_SCRIPT="/root/subvortex/subvortex/miner/neuron/scripts/neuron_teardown.sh"
75+
if [[ -x "$NEURON_SCRIPT" ]]; then
76+
"$NEURON_SCRIPT" --execution "$SV_EXECUTION" || echo "⚠️ Teardown Neuron failed"
77+
echo "✅ Miner teardown complete."
78+
else
79+
echo "⚠️ Neuron teardown script not found or not executable: $NEURON_SCRIPT"
80+
fi
81+
82+
# --- WAIT NEW MINER STOP ---
83+
sleep 5
84+
85+
# --- START OLD MINER ---
86+
echo
87+
echo "🧐 Choose how the old Miner should be started:"
88+
echo " 1) systemd service"
89+
echo " 2) background process (PM2)"
90+
echo " 3) Docker container"
91+
read -rp "⚙️ Enter option [1/2/3]: " val_mode
92+
93+
case "$val_mode" in
94+
1)
95+
read -rp "⚙️ Enter systemd service name: " val_svc
96+
echo "🔼 Starting systemd service '$val_svc'..."
97+
sudo systemctl start "$val_svc" || echo "⚠️ Failed to start systemd service"
98+
;;
99+
2)
100+
read -rp "⚙️ Enter PM2 process name: " val_proc
101+
echo "🔼 Starting PM2 process '$val_proc'..."
102+
pm2 start "$val_proc" || echo "⚠️ Failed to start PM2 process"
103+
;;
104+
3)
105+
read -rp "🐳 Enter Docker container name or ID: " val_container
106+
echo "🔼 Starting Docker container '$val_container'..."
107+
docker start "$val_container" || echo "⚠️ Failed to start container"
108+
;;
109+
*)
110+
echo "⚠️ Invalid option. Skipping miner start."
111+
;;
112+
esac
113+
114+
# --- CLEAN WORKSPACE ---
115+
echo "🧹 Cleaning auto upgrader workspace..."
116+
./scripts/quick_clean.sh --workspace --remove || echo "⚠️ Cleaning failed"
117+
118+
# --- TEARDOWN AUTO UPGRADER ---
119+
if [[ "$SKIP_AUTO_UPGRADER" == "false" ]]; then
120+
echo "🧨 Teardown the Auto Upgrader..."
121+
./scripts/auto_upgrader/auto_upgrader_teardown.sh --execution "$AU_EXECUTION" || echo "⚠️ Teardown Auto Upgrader failed"
122+
fi
123+
124+
echo "✅ Miner installed and started successfully."

0 commit comments

Comments
 (0)