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

Run sever command #193

Merged
merged 10 commits into from
Mar 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"
autotests = false

[dependencies]
anyhow = "1.0.56"
anyhow = { version = "1.0.56", features = ["backtrace"] }
axum = "0.4.8"
axum-server = "0.3.3"
bitcoin = "0.27.1"
Expand Down
6 changes: 4 additions & 2 deletions deploy/checkout
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

set -euxo pipefail

branch=$1

if [[ ! -d ord ]]; then
git clone https://github.com/casey/ord.git
fi

cd ord

git fetch origin
git checkout -B master
git reset --hard origin/master
git checkout -B $1
git reset --hard origin/$1
./deploy/setup
6 changes: 4 additions & 2 deletions deploy/ord.service
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ StartLimitIntervalSec=10m

[Service]
WorkingDirectory=/var/lib/ord
Environment="RUST_LOG=info"
Environment=RUST_BACKTRACE=1
Environment=RUST_LOG=info
ExecStart=/usr/local/bin/ord \
--index-size 1TiB \
--rpc-url 127.0.0.1:8332 \
--cookie-file /var/lib/bitcoind/.cookie \
index
server \
--port 8000

# Process management
####################
Expand Down
3 changes: 2 additions & 1 deletion deploy/setup
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ fi
source ~/.cargo/env

cargo build --release
cp target/release/ord /usr/local/bin/ord

id --user bitcoin || useradd --system bitcoin
id --user ord || useradd --system ord
Expand All @@ -31,5 +30,7 @@ setfacl -m ord:r /var/lib/bitcoind/.cookie

cp deploy/ord.service /etc/systemd/system/
systemctl daemon-reload
systemctl stop ord
cp target/release/ord /usr/local/bin/ord
systemctl enable ord
systemctl restart ord
4 changes: 2 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ watch +args='ltest':
install-dev-deps:
cargo install cargo-criterion

deploy:
deploy branch='master':
ssh root@65.108.68.37 mkdir -p deploy
rsync -avz deploy/checkout root@65.108.68.37:deploy/checkout
ssh root@65.108.68.37 'cd deploy && ./checkout'
ssh root@65.108.68.37 'cd deploy && ./checkout {{branch}}'

status:
ssh root@65.108.68.37 systemctl status bitcoind
Expand Down
2 changes: 1 addition & 1 deletion src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl Index {
let sleep_until = self.sleep_until.get();

if sleep_until > now {
std::thread::sleep(sleep_until - now);
thread::sleep(sleep_until - now);
}

self
Expand Down
8 changes: 8 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use {
cell::Cell,
cmp::Ordering,
collections::VecDeque,
env,
fmt::{self, Display, Formatter},
io,
net::ToSocketAddrs,
Expand All @@ -33,6 +34,7 @@ use {
atomic::{self, AtomicU64},
Arc, Mutex,
},
thread,
time::{Duration, Instant},
},
tokio::runtime::Runtime,
Expand Down Expand Up @@ -86,6 +88,12 @@ fn main() {

if let Err(error) = Arguments::parse().run() {
eprintln!("error: {}", error);
if env::var_os("RUST_BACKTRACE")
.map(|val| val == "1")
.unwrap_or_default()
{
eprintln!("{}", error.backtrace());
}
process::exit(1);
}
}