Skip to content

Commit

Permalink
Allow docker/pm2 to restart
Browse files Browse the repository at this point in the history
  • Loading branch information
MsRandom committed Nov 12, 2024
1 parent 64f6c39 commit 7391588
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 24 deletions.
5 changes: 3 additions & 2 deletions validator/generate_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

API_SERVICE_TEMPLATE = """
api-{id}:
restart: unless-stopped
restart: always
build:
context: ../
Expand All @@ -31,7 +31,7 @@

VALIDATOR_SERVICE_TEMPLATE = """
validator:
restart: unless-stopped
restart: always
build:
context: ../
Expand All @@ -53,6 +53,7 @@
DEPENDENCY_TEMPLATE = """
api-{id}:
condition: service_healthy
restart: true
"""


Expand Down
2 changes: 1 addition & 1 deletion validator/submission_tester/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ def flush(self):

@asynccontextmanager
async def lifespan(_: FastAPI):
auto_updater = AutoUpdater()
if not debug:
CURRENT_CONTEST.validate()

yield {
"benchmarker": Benchmarker(),
}

auto_updater = AutoUpdater()
app = FastAPI(lifespan=lifespan)


Expand Down
19 changes: 6 additions & 13 deletions validator/submission_tester/start.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
#!/bin/bash

if [ "$EUID" -ne 0 ]; then
echo "This script must be run as root"
exit 1
fi

while true; do
sudo -u api /home/api/.local/bin/uv run uvicorn "$@"
exit_code=$?
sudo -u api /home/api/.local/bin/uv run uvicorn "$@"
exit_code=$?

if [ $exit_code -eq 75 ]; then
echo "Auto update initiated, updating dependencies and restarting API"
./submission_tester/update.sh
fi
done
if [ $exit_code -eq 75 ]; then
echo "Auto update initiated, updating dependencies and restarting API"
./submission_tester/update.sh
fi
2 changes: 1 addition & 1 deletion validator/weight_setting/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ COPY README.md .
COPY validator/base_validator/__init__.py validator/base_validator/
COPY validator/submission_tester/__init__.py validator/submission_tester/
COPY validator/weight_setting/__init__.py validator/weight_setting/
COPY --chown=api:api .git .git

USER root
RUN chown -R validator:validator /app
Expand All @@ -33,7 +34,6 @@ ENV PATH="/home/validator/.local/bin:$PATH"

RUN uv sync

COPY --chown=api:api .git .git
COPY validator/base_validator base_validator
COPY validator/weight_setting weight_setting
COPY neuron/neuron ../neuron/neuron
Expand Down
12 changes: 5 additions & 7 deletions validator/weight_setting/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
chown -R validator:validator /home/validator/.bittensor
chown -R validator:validator /home/validator/.netrc

while true; do
sudo -u validator /home/validator/.local/bin/uv run start_validator "$@"
exit_code=$?
sudo -u validator /home/validator/.local/bin/uv run start_validator "$@"
exit_code=$?

if [ $exit_code -eq 75 ]; then
echo "Auto update initiated, restarting Validator"
fi
done
if [ $exit_code -eq 75 ]; then
echo "Auto update initiated, restarting Validator"
fi

0 comments on commit 7391588

Please sign in to comment.