Skip to content

Commit

Permalink
feat: expose logging for both scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan-Kim2028 committed Nov 22, 2024
1 parent d205231 commit 035d9bc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ services:
- DB_PASSWORD=${DB_PASSWORD}
- DB_HOST=mev_timescaledb
- DB_PORT=${DB_PORT}
- PYTHONUNBUFFERED=1
tty: true
logging:
driver: "json-file"
options:
max-size: "200m"
max-file: "10"
restart: unless-stopped

volumes:
Expand Down
23 changes: 8 additions & 15 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,23 @@
# Activate the virtual environment
source /app/.venv/bin/activate

# Function to run Python scripts
# Function to run Python scripts with unbuffered output
run_scripts() {
echo "Running main.py..."
python main.py &
# Use python -u for unbuffered output
PYTHONUNBUFFERED=1 python -u main.py &
MAIN_PID=$!

echo "Running fetch_l1_txs.py..."
python fetch_l1_txs.py &
PYTHONUNBUFFERED=1 python -u fetch_l1_txs.py &
FETCH_PID=$!

# Wait for both processes
wait $MAIN_PID
wait $FETCH_PID
# Wait for both processes and forward their signals
wait $MAIN_PID $FETCH_PID
}

# Trap SIGTERM and kill child processes
trap 'kill $(jobs -p)' SIGTERM

# Initial run
run_scripts

# Loop to run the scripts every 30 seconds
while true; do
echo "Waiting for 30 seconds before the next run..."
sleep 30
run_scripts
done
# Run the scripts
run_scripts

0 comments on commit 035d9bc

Please sign in to comment.