Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ord dev deploy #2228

Merged
merged 12 commits into from
Jun 30, 2023
21 changes: 0 additions & 21 deletions bin/update-ord-dev

This file was deleted.

33 changes: 33 additions & 0 deletions deploy/deploy-ord-dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
set -euxo pipefail

# This script deploys whatever is currently
# in working directory to our dev server
DOMAIN="ordinals-dev.com"

# Current local working state
BRANCH=$(git rev-parse --abbrev-ref HEAD)
COMMIT=$(git rev-parse --short HEAD)
DIR="ord-${BRANCH}-${COMMIT}"

$EDITOR ./deploy/ord-dev.service
raphjaph marked this conversation as resolved.
Show resolved Hide resolved

# Create own directory for every deploy
ssh root@${DOMAIN} "mkdir -p /var/lib/ord/${DIR}/repo"
rsync -avz --exclude-from='.gitignore' --exclude ".git" --exclude "*.redb" ./ root@${DOMAIN}:/var/lib/ord/${DIR}/repo

# Store deployment info in environmental variables
ssh root@${DOMAIN} "echo 'BRANCH=${BRANCH}' >> /etc/environment \
&& echo 'COMMIT=${COMMIT}' >> /etc/environment \
&& echo 'DIR=${DIR}' >> /etc/environment"

# Deploy
ssh root@${DOMAIN} "cd /var/lib/ord/${DIR}/repo \
&& /root/.cargo/bin/cargo build --release \
&& systemctl stop ord-dev \
&& cp ./target/release/ord /usr/local/bin/ord \
&& cp /var/lib/ord/${DIR}/repo/deploy/ord-dev.service /etc/systemd/system/ \
&& systemctl daemon-reload \
&& systemctl enable ord-dev \
&& systemctl restart ord-dev \
&& systemctl status ord-dev"
19 changes: 12 additions & 7 deletions deploy/ord-dev.service
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ StartLimitIntervalSec=10m
AmbientCapabilities=CAP_NET_BIND_SERVICE
Environment=RUST_BACKTRACE=1
Environment=RUST_LOG=info
ExecStart=/usr/local/bin/ord-dev \
ExecStart=/usr/local/bin/ord \
--bitcoin-data-dir /var/lib/bitcoind \
--chain ${CHAIN} \
--data-dir /var/lib/ord-dev \
--index-sats \
--data-dir /var/lib/ord \
# --index-sats \
server \
--http-port 8080
--acme-contact mailto:casey@rodarmor.com \
--http \
--https
Group=ord
LimitNOFILE=65536
MemoryDenyWriteExecute=true
NoNewPrivileges=true
PrivateDevices=true
Expand All @@ -24,9 +26,12 @@ ProtectHome=true
ProtectSystem=full
Restart=on-failure
RestartSec=5s
StateDirectory=ord-dev
StateDirectory=ord
StateDirectoryMode=0700
TimeoutStopSec=10m
Type=simple
User=ord
WorkingDirectory=/var/lib/ord-dev
WorkingDirectory=/var/lib/ord

[Install]
WantedBy=multi-user.target
17 changes: 17 additions & 0 deletions deploy/save-ord-dev-state
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
set -euo pipefail

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

cd /var/lib/ord

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

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

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

17 changes: 7 additions & 10 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +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":
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 Expand Up @@ -69,16 +76,6 @@ open:
doc:
cargo doc --all --open

update-ord-dev:
./bin/update-ord-dev

rebuild-ord-dev-database: && update-ord-dev
systemctl stop ord-dev
rm -f /var/lib/ord-dev/index.redb
rm -f /var/lib/ord-dev/*/index.redb
journalctl --unit ord-dev --rotate
journalctl --unit ord-dev --vacuum-time 1s

prepare-release revision='master':
#!/usr/bin/env bash
set -euxo pipefail
Expand Down
Loading