diff --git a/Cargo.lock b/Cargo.lock index 3387206ed2..7586cbc572 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,21 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "addr2line" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + [[package]] name = "aho-corasick" version = "0.7.18" @@ -16,6 +31,9 @@ name = "anyhow" version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4361135be9122e0870de935d7c439aef945b9f9ddd4199a553b5270b49c82a27" +dependencies = [ + "backtrace", +] [[package]] name = "async-trait" @@ -104,6 +122,21 @@ dependencies = [ "tower-service", ] +[[package]] +name = "backtrace" +version = "0.3.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e121dee8023ce33ab248d9ce1493df03c3b38a659b240096fcbd7048ff9c31f" +dependencies = [ + "addr2line", + "cc", + "cfg-if 1.0.0", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + [[package]] name = "base64" version = "0.13.0" @@ -660,6 +693,12 @@ dependencies = [ "wasi 0.10.0+wasi-snapshot-preview1", ] +[[package]] +name = "gimli" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" + [[package]] name = "globset" version = "0.4.8" @@ -1089,6 +1128,16 @@ version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" +[[package]] +name = "miniz_oxide" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" +dependencies = [ + "adler", + "autocfg", +] + [[package]] name = "mio" version = "0.8.2" @@ -1192,6 +1241,15 @@ dependencies = [ "libc", ] +[[package]] +name = "object" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67ac1d3f9a1d3616fd9a60c8d74296f22406a238b6a72f5cc1e6f314df4ffbf9" +dependencies = [ + "memchr", +] + [[package]] name = "once_cell" version = "1.10.0" @@ -1630,6 +1688,12 @@ dependencies = [ "winreg", ] +[[package]] +name = "rustc-demangle" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" + [[package]] name = "rustc_version" version = "0.4.0" diff --git a/Cargo.toml b/Cargo.toml index 2d3c1064a3..acd82ca4fe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/deploy/checkout b/deploy/checkout index 47a773554c..2b2aedf7ae 100755 --- a/deploy/checkout +++ b/deploy/checkout @@ -2,6 +2,8 @@ set -euxo pipefail +branch=$1 + if [[ ! -d ord ]]; then git clone https://github.com/casey/ord.git fi @@ -9,6 +11,6 @@ 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 diff --git a/deploy/ord.service b/deploy/ord.service index a77ec04fb4..b5bb54419b 100644 --- a/deploy/ord.service +++ b/deploy/ord.service @@ -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 #################### diff --git a/deploy/setup b/deploy/setup index a28ca6f3e9..8633227eab 100755 --- a/deploy/setup +++ b/deploy/setup @@ -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 @@ -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 diff --git a/justfile b/justfile index 8728e8e723..d89f0c2238 100644 --- a/justfile +++ b/justfile @@ -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 diff --git a/src/index.rs b/src/index.rs index fde9599318..4087cbda0e 100644 --- a/src/index.rs +++ b/src/index.rs @@ -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 diff --git a/src/main.rs b/src/main.rs index 2485e45ca1..970597c113 100644 --- a/src/main.rs +++ b/src/main.rs @@ -22,6 +22,7 @@ use { cell::Cell, cmp::Ordering, collections::VecDeque, + env, fmt::{self, Display, Formatter}, io, net::ToSocketAddrs, @@ -33,6 +34,7 @@ use { atomic::{self, AtomicU64}, Arc, Mutex, }, + thread, time::{Duration, Instant}, }, tokio::runtime::Runtime, @@ -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); } }