From 72a65c2abb22e76c17d9c69c09c6e060ccc837e0 Mon Sep 17 00:00:00 2001 From: Gary Verhaegen Date: Thu, 8 Apr 2021 18:28:07 +0200 Subject: [PATCH] fix hoogle After #9362, hoogle stopped returning any result. It was up and running, but with an empty database. Problem was two-fold: 1. In the switch to `nix`, I lost track of the fact that we were previously doing all the work in `~/hoogle` rather than `~/`, which broke the periodic refresh. 2. The initial setup has been broken for months; machines have been initializing with an empty DB and only getting data on the first refresh since #7370. CHANGELOG_BEGIN CHANGELOG_END --- infra/hoogle_server.tf | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/infra/hoogle_server.tf b/infra/hoogle_server.tf index 14d077725266..d20526a8f469 100644 --- a/infra/hoogle_server.tf +++ b/infra/hoogle_server.tf @@ -115,34 +115,26 @@ NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs/archive/c50e680b03adecae01fdd1 HOOGLE_PATH=$(nix-build --no-out-link -E '(import {}).haskellPackages.hoogle') mkdir -p /home/hoogle/.local/bin ln -s $HOOGLE_PATH/bin/hoogle /home/hoogle/.local/bin/hoogle -export PATH=/home/hoogle/.local/bin:$PATH -mkdir daml -curl https://docs.daml.com/hoogle_db/base.txt --output daml/base.txt -hoogle generate --database=daml.hoo --local=daml -nohup hoogle server --database=daml.hoo --log=.log.txt --port=8080 >> out.txt & -HOOGLE_SETUP -cat > /home/hoogle/refresh-db.sh < /home/hoogle/refresh-db.sh <> /home/hoogle/cron_log.txt } log "Checking for new DAML version..." -cd /home/hoogle/hoogle +cd /home/hoogle mkdir new-daml -if ! curl --fail -s https://docs.daml.com/hoogle_db/base.txt --output new-daml/base.txt; then - curl -s https://docs.daml.com/hoogle_db.tar.gz --output db.tar.gz - tar xzf db.tar.gz -C new-daml --strip-components=1 -fi +curl -s https://docs.daml.com/hoogle_db.tar.gz --output db.tar.gz +tar xzf db.tar.gz -C new-daml --strip-components=1 if ! diff -rq daml new-daml; then log "New version detected. Creating database..." rm -rf daml mv new-daml daml - rm daml.hoo + rm -f daml.hoo /home/hoogle/.local/bin/hoogle generate --database=daml.hoo --local=daml log "Killing running instance..." - killall hoogle - log "Stating new server..." + killall hoogle || true + log "Starting new server..." nohup /home/hoogle/.local/bin/hoogle server --database=daml.hoo --log=.log.txt --port=8080 >> out.txt & log "New server started." else @@ -150,10 +142,13 @@ else rm -rf new-daml fi log "Done." -CRON +MAKE_DB chmod +x /home/hoogle/refresh-db.sh -chown hoogle:hoogle /home/hoogle/refresh-db.sh -echo "*/5 * * * * /home/hoogle/refresh-db.sh" | crontab -u hoogle - +./refresh-db.sh +echo "*/5 * * * * /home/hoogle/refresh-db.sh" | crontab - +echo "Successfully ran startup script." +tail -f cron_log.txt +HOOGLE_SETUP STARTUP network_interface { @@ -204,7 +199,7 @@ resource "google_compute_instance_group_manager" "hoogle" { health_check = google_compute_health_check.hoogle-https.self_link # Compiling hoogle takes some time - initial_delay_sec = 2500 + initial_delay_sec = 600 } update_policy {