Skip to content

Commit

Permalink
Clean up deploy scripts (#2298)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphjaph authored Jul 23, 2023
1 parent 919e010 commit 3170899
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 81 deletions.
5 changes: 4 additions & 1 deletion deploy/checkout
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ cd ord
git fetch origin
git checkout -B $BRANCH
git reset --hard origin/$BRANCH
./deploy/setup $CHAIN $DOMAIN

COMMIT=$(git rev-parse --short HEAD)

./deploy/setup $CHAIN $DOMAIN $BRANCH $COMMIT
34 changes: 0 additions & 34 deletions deploy/deploy-ord-dev

This file was deleted.

37 changes: 0 additions & 37 deletions deploy/ord-dev.service

This file was deleted.

12 changes: 8 additions & 4 deletions deploy/save-ord-dev-state
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@
set -euo pipefail

# Stops, copies index and exports state of running instance
systemctl stop ord-dev
systemctl stop ord

cd /var/lib/ord

# Still have to manually set --index-sats or --height-limit
mkdir -p /var/lib/ord/$REVISION

# Still have to manually set --index-sats or --heigh-limit
# --height-limit 100000 \
/usr/local/bin/ord --bitcoin-data-dir /var/lib/bitcoind \
--data-dir /var/lib/ord \
--index-sats \
index export

mv inscription_number_to_id.tsv ./${DIR}/inscription_number_to_id-${BRANCH}-${COMMIT}.tsv
mv inscription_number_to_id.tsv ./$REVISION/inscription_number_to_id-$BRANCH-$COMMIT.tsv

mv index.redb ./${DIR}/index-${BRANCH}-${COMMIT}.redb
mv index.redb ./$REVISION/index-$BRANCH-$COMMIT.redb

12 changes: 11 additions & 1 deletion deploy/setup
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
#!/usr/bin/env bash

# This script is idempotent in the sense that running it more
# than once will not change the state beyond the initial application

set -euxo pipefail

CHAIN=$1
DOMAIN=$2
BRANCH=$3
COMMIT=$4
REVISION="ord-$BRANCH-$COMMIT"

touch ~/.hushlogin

Expand All @@ -17,6 +23,10 @@ printf "[Service]\nEnvironment=CHAIN=%s\n" $CHAIN \
| tee /etc/systemd/system/bitcoind.service.d/override.conf \
> /etc/systemd/system/ord.service.d/override.conf

printf 'BRANCH=%s\n' $BRANCH >> /etc/environment \
&& printf 'COMMIT=%s\n' $COMMIT >> /etc/environment \
&& printf 'REVISION=%s\n' $REVISION >> /etc/environment

hostnamectl set-hostname $DOMAIN

apt-get install --yes \
Expand Down Expand Up @@ -70,7 +80,7 @@ rustup update stable

cargo build --release
if [[ -f /usr/local/bin/ord ]]; then
mv /usr/local/bin/ord /usr/local/bin/ord.bak
mv /usr/local/bin/ord /usr/local/bin/$REVISION.bak
fi
cp target/release/ord /usr/local/bin/ord

Expand Down
8 changes: 4 additions & 4 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ deploy-signet branch="master": (deploy branch "signet" "signet.ordinals.net")

deploy-testnet branch="master": (deploy branch "test" "testnet.ordinals.net")

ord-dev-save-state domain="ordinals-dev.com":
deploy-ord-dev branch="master" chain="main" domain="ordinals-dev.com": (deploy branch chain domain)

save-ord-dev-state domain="ordinals-dev.com":
$EDITOR ./deploy/save-ord-dev-state
scp ./deploy/save-ord-dev-state root@{{domain}}:~
ssh root@{{domain}} "./save-ord-dev-state"

ord-dev-deploy:
./deploy/deploy-ord-dev

log unit="ord" domain="ordinals.net":
ssh root@{{domain}} 'journalctl -fu {{unit}}'

Expand Down

0 comments on commit 3170899

Please sign in to comment.