Skip to content

Commit

Permalink
scripts: various improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
pulsejet committed May 11, 2024
1 parent 402e67f commit c032e4b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ The master service runs internal cron jobs for polling. You can trigger these ma

```bash
# cron-master pulls the git repo and restarts containers if required
docker compose exec master bash /testbed/scripts/cron-master.sh
docker compose exec master -e "SKIP_SLEEP=1" bash /testbed/scripts/cron-master.sh

# cron-status regenerates status json
docker compose exec master bash /testbed/scripts/cron-status.sh
docker compose exec master -e "SKIP_SLEEP=1" bash /testbed/scripts/cron-status.sh
```

## Unattended Upgrades
Expand Down
12 changes: 8 additions & 4 deletions scripts/cron-host.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ source "$(pwd)/scripts/utils.sh"
# Check if debug mode is enabled
source .env
if [[ -n "$DEBUG" ]]; then
echo "Skipping job because DEBUG is enabled"
echo -e "Skipping job because DEBUG is enabled" >&2
exit 0
fi

# Sleep for random time
sleep 10
random_sleep 60
if [[ -z "$SKIP_SLEEP" ]]; then
sleep 10
random_sleep 60
fi

# Ensure services are running
docker compose up -d --remove-orphans
docker compose up -d --remove-orphans

echo -e "Finished cron-host at $(date)" >&2
8 changes: 5 additions & 3 deletions scripts/cron-master.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ source "$(pwd)/scripts/utils.sh"
# Check if debug mode is enabled
source .env
if [[ -n "$DEBUG" ]]; then
echo "Skipping job because DEBUG is enabled"
echo -e "Skipping job because DEBUG is enabled" >&2
exit 0
fi

# Prevent a thundering herd
random_sleep 120
if [[ -z "$SKIP_SLEEP" ]]; then
random_sleep 120
fi

git pull

PWD="${ROOT_DIR}" python3 framework/main.py

echo -e "Finished cron-master at $(date)"
echo -e "Finished cron-master at $(date)" >&2
4 changes: 2 additions & 2 deletions scripts/cron-status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ STATUS=$(python3 framework/status-json.py)
echo -e "$STATUS" > dist/file-server/status.json

# Done
echo -e "Status updated at $(date)"
echo -e "Status updated at $(date)" >&2

# Collect all statuses if enabled
if [[ -n "$COLLECT_STATUS_GLOBAL" ]]; then
echo -e "Waiting before starting global status job ..."
echo -e "Waiting 60s before starting global status job ..." >&2
sleep 60

GLOBAL_STATUS=$(python3 framework/status-global.py)
Expand Down
4 changes: 2 additions & 2 deletions scripts/master.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

set -e

echo -e "Starting master service at $(date)"
echo -e "Starting master service at $(date)" >&2

# Change directory to the root of the project
cd "$(dirname "${BASH_SOURCE[0]}")"/..
Expand All @@ -27,7 +27,7 @@ if [[ -z "$DEBUG" ]]; then
bash dist/nlsr/renew.sh
bash dist/ndn-python-repo/renew.sh
else
echo -e "Skipping initial repo pull and bootstrap because DEBUG=1"
echo -e "Skipping initial repo pull and bootstrap because DEBUG=1" >&2
fi

# End bootstrapping
Expand Down

0 comments on commit c032e4b

Please sign in to comment.