Spawn daemon in separate process (this should fail in CI)
This commit is contained in:
parent
49afb020c1
commit
f92c44ab59
2
.github/workflows/build.yaml
vendored
2
.github/workflows/build.yaml
vendored
|
@ -41,7 +41,7 @@ jobs:
|
||||||
|
|
||||||
- name: Build package and create closure for ${{ matrix.systems.system }}
|
- name: Build package and create closure for ${{ matrix.systems.system }}
|
||||||
run: |
|
run: |
|
||||||
nix build .# -L --fallback && \
|
nix build .# -L --fallback
|
||||||
nix-store --export $(nix-store -qR ./result) | xz -9 > "${{ env.ARCHIVE_NAME }}"
|
nix-store --export $(nix-store -qR ./result) | xz -9 > "${{ env.ARCHIVE_NAME }}"
|
||||||
|
|
||||||
- name: Upload magic-nix-cache closure for ${{ matrix.systems.system }}
|
- name: Upload magic-nix-cache closure for ${{ matrix.systems.system }}
|
||||||
|
|
|
@ -26,6 +26,7 @@ use std::io::Write;
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
use std::os::unix::fs::PermissionsExt;
|
use std::os::unix::fs::PermissionsExt;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
use std::process::exit;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use ::attic::nix_store::NixStore;
|
use ::attic::nix_store::NixStore;
|
||||||
|
@ -370,6 +371,21 @@ async fn main_cli() -> Result<()> {
|
||||||
|
|
||||||
tracing::info!("Listening on {}", args.listen);
|
tracing::info!("Listening on {}", args.listen);
|
||||||
|
|
||||||
|
let server = axum::Server::bind(&args.listen)
|
||||||
|
.serve(app.into_make_service())
|
||||||
|
.with_graceful_shutdown(async move {
|
||||||
|
shutdown_receiver.await.ok();
|
||||||
|
tracing::info!("Shutting down");
|
||||||
|
});
|
||||||
|
|
||||||
|
// Spawn here so that post-startup tasks can proceed
|
||||||
|
tokio::spawn(async move {
|
||||||
|
if let Err(e) = server.await {
|
||||||
|
tracing::error!("failed to start up daemon: {e}");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Notify of startup via HTTP
|
// Notify of startup via HTTP
|
||||||
if let Some(startup_notification_url) = args.startup_notification_url {
|
if let Some(startup_notification_url) = args.startup_notification_url {
|
||||||
tracing::debug!("Startup notification via HTTP POST to {startup_notification_url}");
|
tracing::debug!("Startup notification via HTTP POST to {startup_notification_url}");
|
||||||
|
@ -411,21 +427,11 @@ async fn main_cli() -> Result<()> {
|
||||||
tracing::debug!("Created startup notification file at {startup_notification_file_path:?}");
|
tracing::debug!("Created startup notification file at {startup_notification_file_path:?}");
|
||||||
}
|
}
|
||||||
|
|
||||||
let ret = axum::Server::bind(&args.listen)
|
|
||||||
.serve(app.into_make_service())
|
|
||||||
.with_graceful_shutdown(async move {
|
|
||||||
shutdown_receiver.await.ok();
|
|
||||||
tracing::info!("Shutting down");
|
|
||||||
})
|
|
||||||
.await;
|
|
||||||
|
|
||||||
// Notify diagnostics endpoint
|
// Notify diagnostics endpoint
|
||||||
if let Some(diagnostic_endpoint) = diagnostic_endpoint {
|
if let Some(diagnostic_endpoint) = diagnostic_endpoint {
|
||||||
state.metrics.send(diagnostic_endpoint).await;
|
state.metrics.send(diagnostic_endpoint).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret?;
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue