Handle tokio task failure case
@@ -243,6 +243,8 @@ async fn run_server(addr: SocketAddr) -> anyhow::Result<()> {
// spawning a background task that will run the scheduled jobs
// every JOB_PROCESSING_CADENCE_IN_SECS
task::spawn(async move {
+ loop {
+ let res = task::spawn(async move {
let pool = db::ClientPool::new();
loop {
@@ -255,6 +257,19 @@ async fn run_server(addr: SocketAddr) -> anyhow::Result<()> {
}
});
+ match res.await {
+ Err(err) if err.is_panic() => {
+ /* handle panic in above task, re-launching */
+ tracing::trace!("run_scheduled_jobs task died (error={})", err);
+ }
+ _ => {
+ /* break in other case by default */
+ break;
+ }
+ }
+ }
+ });
+
let client = Client::new();
let gh = github::GithubClient::new_with_default_token(client.clone());
let oc = octocrab::OctocrabBuilder::new()
