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

fix: drop the manager handler correctly #107

Merged
merged 1 commit into from
Dec 14, 2023
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
6 changes: 3 additions & 3 deletions tap-agent/src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::{
tap::sender_allocation_relationships_manager::SenderAllocationRelationshipsManager,
};

pub async fn start_agent(config: &'static config::Cli) {
pub async fn start_agent(config: &'static config::Cli) -> SenderAllocationRelationshipsManager {
let pgpool = database::connect(&config.postgres).await;

let http_client = reqwest::Client::new();
Expand Down Expand Up @@ -79,7 +79,7 @@ pub async fn start_agent(config: &'static config::Cli) {
verifying_contract: config.receipts.receipts_verifier_address,
};

let _sender_allocation_relationships_manager = SenderAllocationRelationshipsManager::new(
SenderAllocationRelationshipsManager::new(
config,
pgpool,
indexer_allocations,
Expand All @@ -88,5 +88,5 @@ pub async fn start_agent(config: &'static config::Cli) {
tap_eip712_domain_separator,
sender_aggregator_endpoints,
)
.await;
.await
}
27 changes: 15 additions & 12 deletions tap-agent/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,22 @@ async fn main() -> Result<()> {
lazy_static::initialize(&CONFIG);
debug!("Config: {:?}", *CONFIG);

agent::start_agent(&CONFIG).await;
info!("TAP Agent started.");

// Have tokio wait for SIGTERM or SIGINT.
let mut signal_sigint = signal(SignalKind::interrupt())?;
let mut signal_sigterm = signal(SignalKind::terminate())?;
tokio::select! {
_ = signal_sigint.recv() => debug!("Received SIGINT."),
_ = signal_sigterm.recv() => debug!("Received SIGTERM."),
{
let _manager = agent::start_agent(&CONFIG).await;
info!("TAP Agent started.");

// Have tokio wait for SIGTERM or SIGINT.
let mut signal_sigint = signal(SignalKind::interrupt())?;
let mut signal_sigterm = signal(SignalKind::terminate())?;
tokio::select! {
_ = signal_sigint.recv() => debug!("Received SIGINT."),
_ = signal_sigterm.recv() => debug!("Received SIGTERM."),
}

// If we're here, we've received a signal to exit.
info!("Shutting down...");
}

// If we're here, we've received a signal to exit.
info!("Shutting down...");
// Manager should be successfully dropped here.

// Stop the server and wait for it to finish gracefully.
debug!("Goodbye!");
Expand Down