Skip to content

Commit

Permalink
fix hoogle
Browse files Browse the repository at this point in the history
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
  • Loading branch information
garyverhaegen-da committed Apr 8, 2021
1 parent c220e05 commit 72a65c2
Showing 1 changed file with 15 additions and 20 deletions.
35 changes: 15 additions & 20 deletions infra/hoogle_server.tf
Original file line number Diff line number Diff line change
Expand Up @@ -115,45 +115,40 @@ NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs/archive/c50e680b03adecae01fdd1
HOOGLE_PATH=$(nix-build --no-out-link -E '(import <nixpkgs> {}).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 <<CRON
cat > /home/hoogle/refresh-db.sh <<MAKE_DB
#!/usr/bin/env bash
set -euxo pipefail
set -euo pipefail
log() {
echo "[\$(date -Is)] \$1" >> /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
log "No change detected."
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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 72a65c2

Please sign in to comment.