Skip to content

Commit

Permalink
Print server URLs on startup (#1015)
Browse files Browse the repository at this point in the history
  • Loading branch information
casey authored Dec 20, 2022
1 parent 365adb1 commit 9313dc5
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
4 changes: 1 addition & 3 deletions src/index/updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ impl Updater {
let mut progress_bar = if cfg!(test)
|| log_enabled!(log::Level::Info)
|| starting_height <= self.height
|| env::var_os("ORD_DISABLE_PROGRESS_BAR")
.map(|value| value.len() > 0)
.unwrap_or(false)
|| integration_test()
{
None
} else {
Expand Down
6 changes: 6 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ const CYCLE_EPOCHS: u64 = 6;
static INTERRUPTS: AtomicU64 = AtomicU64::new(0);
static LISTENERS: Mutex<Vec<axum_server::Handle>> = Mutex::new(Vec::new());

fn integration_test() -> bool {
env::var_os("ORD_INTEGRATION_TEST")
.map(|value| value.len() > 0)
.unwrap_or(false)
}

fn main() {
env_logger::init();

Expand Down
11 changes: 11 additions & 0 deletions src/subcommand/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,17 @@ impl Server {
.next()
.ok_or_else(|| anyhow!("failed to get socket addrs"))?;

if !integration_test() {
eprintln!(
"Listening on {}://{addr}",
if https_acceptor.is_some() {
"https"
} else {
"http"
}
);
}

Ok(tokio::spawn(async move {
if let Some(acceptor) = https_acceptor {
axum_server::Server::bind(addr)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl TestServer {
tempdir.path().display(),
args.join(" "),
).to_args())
.env("ORD_DISABLE_PROGRESS_BAR", "1")
.env("ORD_INTEGRATION_TEST", "1")
.current_dir(&tempdir)
.spawn().unwrap();

Expand Down

0 comments on commit 9313dc5

Please sign in to comment.