Skip to content

Commit 1e21295

Browse files
Fixes post release 300 (#114)
* allow empty or complex password * check redis version * force root for service scripts
1 parent e9ad572 commit 1e21295

66 files changed

Lines changed: 2052 additions & 472 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,10 @@ untag:
256256
TARGETS += release unrelease prerelease unprerelease
257257
unprerelease:
258258
@VERSION=$$(cat VERSION); \
259+
if ! echo "$$VERSION" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+-(alpha|rc)\.[0-9]+$$'; then \
260+
echo "❌ VERSION must be in format x.x.x-alpha.x or x.x.x-rc.x (got: $$VERSION)"; \
261+
exit 1; \
262+
fi; \
259263
TAG=v$$VERSION; \
260264
$(load_env); \
261265
\
@@ -282,6 +286,10 @@ unprerelease:
282286

283287
prerelease:
284288
@VERSION=$$(cat VERSION); \
289+
if ! echo "$$VERSION" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+-(alpha|rc)\.[0-9]+$$'; then \
290+
echo "❌ VERSION must be in format x.x.x-alpha.x or x.x.x-rc.x (got: $$VERSION)"; \
291+
exit 1; \
292+
fi; \
285293
TAG=v$$VERSION; \
286294
echo "🚀 Creating GitHub prerelease..."; \
287295
gh release create $$TAG \
@@ -294,6 +302,10 @@ prerelease:
294302

295303
unrelease:
296304
@VERSION=$$(cat VERSION); \
305+
if ! echo "$$VERSION" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$$'; then \
306+
echo "❌ VERSION must be in format x.x.x (got: $$VERSION)"; \
307+
exit 1; \
308+
fi; \
297309
TAG=v$$VERSION; \
298310
$(load_env); \
299311
\
@@ -319,6 +331,10 @@ unrelease:
319331
done
320332
release:
321333
@VERSION=$$(cat VERSION); \
334+
if ! echo "$$VERSION" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$$'; then \
335+
echo "❌ VERSION must be in format x.x.x (got: $$VERSION)"; \
336+
exit 1; \
337+
fi; \
322338
TAG=v$$VERSION; \
323339
echo "🚀 Creating GitHub release..."; \
324340
gh release create $$TAG \

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0.0
1+
3.0.1

subvortex/miner/neuron/deployment/docker/neuron_docker_setup.sh

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,37 @@
22

33
set -euo pipefail
44

5-
# Determine script directory dynamically to ensure everything runs in ./scripts/api/
6-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7-
cd "$SCRIPT_DIR/../.."
5+
# Determine working directory: prefer SUBVORTEX_WORKING_DIR, fallback to script location
6+
SCRIPT_DIR="$(cd "$(dirname "$(python3 -c 'import os, sys; print(os.path.abspath(sys.argv[1]))' "$0")")" && pwd)"
7+
8+
# Find project root by walking up until LICENSE is found
9+
find_project_root() {
10+
local dir="$1"
11+
while [[ "$dir" != "/" ]]; do
12+
[[ -f "$dir/LICENSE" ]] && { echo "$dir"; return; }
13+
dir="$(dirname "$dir")"
14+
done
15+
return 1
16+
}
17+
18+
PROJECT_ROOT="$(find_project_root "$SCRIPT_DIR")" || {
19+
echo "❌ Could not detect project root (LICENSE not found)"
20+
exit 1
21+
}
22+
23+
# Resolve final working directory
24+
if [[ -n "${SUBVORTEX_WORKING_DIR:-}" ]]; then
25+
REL_PATH="${SCRIPT_DIR#$PROJECT_ROOT/}"
26+
TARGET_DIR="$SUBVORTEX_WORKING_DIR/$REL_PATH"
27+
[[ -d "$TARGET_DIR" ]] || { echo "❌ Target directory does not exist: $TARGET_DIR"; exit 1; }
28+
echo "📁 Using SUBVORTEX_WORKING_DIR: $TARGET_DIR"
29+
cd "$TARGET_DIR/../.."
30+
else
31+
echo "📁 Using fallback PROJECT_ROOT: $SCRIPT_DIR"
32+
cd "$SCRIPT_DIR/../.."
33+
fi
34+
35+
echo "📍 Working directory: $(pwd)"
836

937
echo "📦 Starting Miner Neuron Docker setup..."
1038

subvortex/miner/neuron/deployment/docker/neuron_docker_start.sh

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,37 @@
22

33
set -euo pipefail
44

5-
# Determine script directory dynamically to ensure everything runs in ./scripts/api/
6-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7-
cd "$SCRIPT_DIR/../.."
5+
# Determine working directory: prefer SUBVORTEX_WORKING_DIR, fallback to script location
6+
SCRIPT_DIR="$(cd "$(dirname "$(python3 -c 'import os, sys; print(os.path.abspath(sys.argv[1]))' "$0")")" && pwd)"
7+
8+
# Find project root by walking up until LICENSE is found
9+
find_project_root() {
10+
local dir="$1"
11+
while [[ "$dir" != "/" ]]; do
12+
[[ -f "$dir/LICENSE" ]] && { echo "$dir"; return; }
13+
dir="$(dirname "$dir")"
14+
done
15+
return 1
16+
}
17+
18+
PROJECT_ROOT="$(find_project_root "$SCRIPT_DIR")" || {
19+
echo "❌ Could not detect project root (LICENSE not found)"
20+
exit 1
21+
}
22+
23+
# Resolve final working directory
24+
if [[ -n "${SUBVORTEX_WORKING_DIR:-}" ]]; then
25+
REL_PATH="${SCRIPT_DIR#$PROJECT_ROOT/}"
26+
TARGET_DIR="$SUBVORTEX_WORKING_DIR/$REL_PATH"
27+
[[ -d "$TARGET_DIR" ]] || { echo "❌ Target directory does not exist: $TARGET_DIR"; exit 1; }
28+
echo "📁 Using SUBVORTEX_WORKING_DIR: $TARGET_DIR"
29+
cd "$TARGET_DIR/../.."
30+
else
31+
echo "📁 Using fallback PROJECT_ROOT: $SCRIPT_DIR"
32+
cd "$SCRIPT_DIR/../.."
33+
fi
34+
35+
echo "📍 Working directory: $(pwd)"
836

937
show_help() {
1038
echo "Usage: $0 [--recreate]"

subvortex/miner/neuron/deployment/docker/neuron_docker_stop.sh

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,37 @@
22

33
set -euo pipefail
44

5-
# Determine script directory dynamically to ensure everything runs in ./scripts/api/
6-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7-
cd "$SCRIPT_DIR/../.."
5+
# Determine working directory: prefer SUBVORTEX_WORKING_DIR, fallback to script location
6+
SCRIPT_DIR="$(cd "$(dirname "$(python3 -c 'import os, sys; print(os.path.abspath(sys.argv[1]))' "$0")")" && pwd)"
7+
8+
# Find project root by walking up until LICENSE is found
9+
find_project_root() {
10+
local dir="$1"
11+
while [[ "$dir" != "/" ]]; do
12+
[[ -f "$dir/LICENSE" ]] && { echo "$dir"; return; }
13+
dir="$(dirname "$dir")"
14+
done
15+
return 1
16+
}
17+
18+
PROJECT_ROOT="$(find_project_root "$SCRIPT_DIR")" || {
19+
echo "❌ Could not detect project root (LICENSE not found)"
20+
exit 1
21+
}
22+
23+
# Resolve final working directory
24+
if [[ -n "${SUBVORTEX_WORKING_DIR:-}" ]]; then
25+
REL_PATH="${SCRIPT_DIR#$PROJECT_ROOT/}"
26+
TARGET_DIR="$SUBVORTEX_WORKING_DIR/$REL_PATH"
27+
[[ -d "$TARGET_DIR" ]] || { echo "❌ Target directory does not exist: $TARGET_DIR"; exit 1; }
28+
echo "📁 Using SUBVORTEX_WORKING_DIR: $TARGET_DIR"
29+
cd "$TARGET_DIR/../.."
30+
else
31+
echo "📁 Using fallback PROJECT_ROOT: $SCRIPT_DIR"
32+
cd "$SCRIPT_DIR/../.."
33+
fi
34+
35+
echo "📍 Working directory: $(pwd)"
836

937
echo "🔍 Loading environment variables from .env..."
1038
export $(grep -v '^#' .env | xargs)

subvortex/miner/neuron/deployment/docker/neuron_docker_teardown.sh

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,37 @@
22

33
set -euo pipefail
44

5-
# Determine script directory dynamically to ensure everything runs in ./scripts/api/
6-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7-
cd "$SCRIPT_DIR/../.."
5+
# Determine working directory: prefer SUBVORTEX_WORKING_DIR, fallback to script location
6+
SCRIPT_DIR="$(cd "$(dirname "$(python3 -c 'import os, sys; print(os.path.abspath(sys.argv[1]))' "$0")")" && pwd)"
7+
8+
# Find project root by walking up until LICENSE is found
9+
find_project_root() {
10+
local dir="$1"
11+
while [[ "$dir" != "/" ]]; do
12+
[[ -f "$dir/LICENSE" ]] && { echo "$dir"; return; }
13+
dir="$(dirname "$dir")"
14+
done
15+
return 1
16+
}
17+
18+
PROJECT_ROOT="$(find_project_root "$SCRIPT_DIR")" || {
19+
echo "❌ Could not detect project root (LICENSE not found)"
20+
exit 1
21+
}
22+
23+
# Resolve final working directory
24+
if [[ -n "${SUBVORTEX_WORKING_DIR:-}" ]]; then
25+
REL_PATH="${SCRIPT_DIR#$PROJECT_ROOT/}"
26+
TARGET_DIR="$SUBVORTEX_WORKING_DIR/$REL_PATH"
27+
[[ -d "$TARGET_DIR" ]] || { echo "❌ Target directory does not exist: $TARGET_DIR"; exit 1; }
28+
echo "📁 Using SUBVORTEX_WORKING_DIR: $TARGET_DIR"
29+
cd "$TARGET_DIR/../.."
30+
else
31+
echo "📁 Using fallback PROJECT_ROOT: $SCRIPT_DIR"
32+
cd "$SCRIPT_DIR/../.."
33+
fi
34+
35+
echo "📍 Working directory: $(pwd)"
836

937
echo "🔍 Loading environment variables from .env..."
1038
export $(grep -v '^#' .env | xargs)

subvortex/miner/neuron/deployment/process/neuron_process_setup.sh

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,37 @@
22

33
set -euo pipefail
44

5-
# Determine script directory dynamically to ensure everything runs in ./scripts/api/
6-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7-
cd "$SCRIPT_DIR/../.."
5+
# Determine working directory: prefer SUBVORTEX_WORKING_DIR, fallback to script location
6+
SCRIPT_DIR="$(cd "$(dirname "$(python3 -c 'import os, sys; print(os.path.abspath(sys.argv[1]))' "$0")")" && pwd)"
7+
8+
# Find project root by walking up until LICENSE is found
9+
find_project_root() {
10+
local dir="$1"
11+
while [[ "$dir" != "/" ]]; do
12+
[[ -f "$dir/LICENSE" ]] && { echo "$dir"; return; }
13+
dir="$(dirname "$dir")"
14+
done
15+
return 1
16+
}
17+
18+
PROJECT_ROOT="$(find_project_root "$SCRIPT_DIR")" || {
19+
echo "❌ Could not detect project root (LICENSE not found)"
20+
exit 1
21+
}
22+
23+
# Resolve final working directory
24+
if [[ -n "${SUBVORTEX_WORKING_DIR:-}" ]]; then
25+
REL_PATH="${SCRIPT_DIR#$PROJECT_ROOT/}"
26+
TARGET_DIR="$SUBVORTEX_WORKING_DIR/$REL_PATH"
27+
[[ -d "$TARGET_DIR" ]] || { echo "❌ Target directory does not exist: $TARGET_DIR"; exit 1; }
28+
echo "📁 Using SUBVORTEX_WORKING_DIR: $TARGET_DIR"
29+
cd "$TARGET_DIR/../.."
30+
else
31+
echo "📁 Using fallback PROJECT_ROOT: $SCRIPT_DIR"
32+
cd "$SCRIPT_DIR/../.."
33+
fi
34+
35+
echo "📍 Working directory: $(pwd)"
836

937
echo "📦 Starting Miner Neuron setup..."
1038

subvortex/miner/neuron/deployment/process/neuron_process_start.sh

Lines changed: 47 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,43 @@
22

33
set -euo pipefail
44

5+
# Determine working directory: prefer SUBVORTEX_WORKING_DIR, fallback to script location
6+
SCRIPT_DIR="$(cd "$(dirname "$(python3 -c 'import os, sys; print(os.path.abspath(sys.argv[1]))' "$0")")" && pwd)"
7+
8+
# Find project root by walking up until LICENSE is found
9+
find_project_root() {
10+
local dir="$1"
11+
while [[ "$dir" != "/" ]]; do
12+
[[ -f "$dir/LICENSE" ]] && { echo "$dir"; return; }
13+
dir="$(dirname "$dir")"
14+
done
15+
return 1
16+
}
17+
18+
PROJECT_ROOT="$(find_project_root "$SCRIPT_DIR")" || {
19+
echo "❌ Could not detect project root (LICENSE not found)"
20+
exit 1
21+
}
22+
23+
# Resolve final working directory
24+
if [[ -n "${SUBVORTEX_WORKING_DIR:-}" ]]; then
25+
REL_PATH="${SCRIPT_DIR#$PROJECT_ROOT/}"
26+
TARGET_DIR="$SUBVORTEX_WORKING_DIR/$REL_PATH"
27+
[[ -d "$TARGET_DIR" ]] || { echo "❌ Target directory does not exist: $TARGET_DIR"; exit 1; }
28+
echo "📁 Using SUBVORTEX_WORKING_DIR: $TARGET_DIR"
29+
cd "$TARGET_DIR/../.."
30+
else
31+
echo "📁 Using fallback PROJECT_ROOT: $SCRIPT_DIR"
32+
cd "$SCRIPT_DIR/../.."
33+
fi
34+
35+
echo "📍 Working directory: $(pwd)"
36+
37+
source ../../scripts/utils.sh
38+
539
NEURON_NAME="subvortex-miner"
640
SERVICE_NAME="$NEURON_NAME-neuron"
741

8-
# Determine script directory dynamically to ensure everything runs in ./scripts/api/
9-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
10-
cd "$SCRIPT_DIR/../.."
11-
1242
# Activate virtual environment
1343
echo "🐍 Activating Python virtual environment..."
1444
source venv/bin/activate
@@ -18,27 +48,17 @@ echo "🔍 Loading environment variables from .env..."
1848
export $(grep -v '^#' .env | xargs)
1949

2050
# Build CLI args from SUBVORTEX_ environment variables
21-
echo "🔧 Building CLI arguments from SUBVORTEX_ environment variables..."
22-
ARGS=()
23-
PREFIX="SUBVORTEX_"
24-
25-
while IFS= read -r line; do
26-
key="${line%%=*}"
27-
value="${line#*=}"
28-
if [[ $key == ${PREFIX}* ]]; then
29-
key_suffix="${key#$PREFIX}"
30-
cli_key="--$(echo "$key_suffix" | tr '[:upper:]' '[:lower:]' | tr '_' '.')"
31-
value_lower="$(echo "$value" | tr '[:upper:]' '[:lower:]')"
32-
33-
if [[ "$value_lower" == "true" ]]; then
34-
ARGS+=("$cli_key")
35-
elif [[ "$value_lower" == "false" ]]; then
36-
continue
37-
else
38-
ARGS+=("$cli_key" "$value")
39-
fi
51+
eval "ARGS=( $(convert_env_var_to_args) )"
52+
53+
# Check for existing PM2 process and remove if config differs
54+
if pm2 jlist | jq -e ".[] | select(.name==\"$SERVICE_NAME\")" > /dev/null; then
55+
EXISTING_CWD="$(pm2 jlist | jq -r ".[] | select(.name==\"$SERVICE_NAME\") | .pm2_env.pm_cwd")"
56+
CURRENT_CWD="$(pwd)"
57+
58+
if [[ "$EXISTING_CWD" != "$CURRENT_CWD" ]]; then
59+
pm2 delete "$SERVICE_NAME"
4060
fi
41-
done < <(env)
61+
fi
4262

4363
# Start or reload PM2 process
4464
echo "🔍 Checking PM2 process: $SERVICE_NAME..."
@@ -52,9 +72,10 @@ if pm2 describe "$SERVICE_NAME" >/dev/null 2>&1; then
5272
fi
5373
else
5474
echo "🚀 No existing process found — starting $SERVICE_NAME via PM2..."
55-
pm2 start src/main.py \
75+
pm2 start "$(pwd)/src/main.py" \
5676
--name "$SERVICE_NAME" \
57-
--interpreter "venv/bin/python3" -- \
77+
--cwd "$(pwd)" \
78+
--interpreter "$(pwd)/venv/bin/python3" -- \
5879
"${ARGS[@]}"
5980
fi
6081

subvortex/miner/neuron/deployment/process/neuron_process_stop.sh

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

33
set -euo pipefail
44

5+
# Determine working directory: prefer SUBVORTEX_WORKING_DIR, fallback to script location
6+
SCRIPT_DIR="$(cd "$(dirname "$(python3 -c 'import os, sys; print(os.path.abspath(sys.argv[1]))' "$0")")" && pwd)"
7+
8+
# Find project root by walking up until LICENSE is found
9+
find_project_root() {
10+
local dir="$1"
11+
while [[ "$dir" != "/" ]]; do
12+
[[ -f "$dir/LICENSE" ]] && { echo "$dir"; return; }
13+
dir="$(dirname "$dir")"
14+
done
15+
return 1
16+
}
17+
18+
PROJECT_ROOT="$(find_project_root "$SCRIPT_DIR")" || {
19+
echo "❌ Could not detect project root (LICENSE not found)"
20+
exit 1
21+
}
22+
23+
# Resolve final working directory
24+
if [[ -n "${SUBVORTEX_WORKING_DIR:-}" ]]; then
25+
REL_PATH="${SCRIPT_DIR#$PROJECT_ROOT/}"
26+
TARGET_DIR="$SUBVORTEX_WORKING_DIR/$REL_PATH"
27+
[[ -d "$TARGET_DIR" ]] || { echo "❌ Target directory does not exist: $TARGET_DIR"; exit 1; }
28+
echo "📁 Using SUBVORTEX_WORKING_DIR: $TARGET_DIR"
29+
cd "$TARGET_DIR/../.."
30+
else
31+
echo "📁 Using fallback PROJECT_ROOT: $SCRIPT_DIR"
32+
cd "$SCRIPT_DIR/../.."
33+
fi
34+
35+
echo "📍 Working directory: $(pwd)"
36+
537
SERVICE_NAME="subvortex-miner-neuron"
638

739
echo "🔍 Checking PM2 process: $SERVICE_NAME..."

0 commit comments

Comments
 (0)