]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/live-manager.ts
Cleanup lives on server restart
[github/Chocobozzz/PeerTube.git] / server / lib / live-manager.ts
index 2702437c42549b2e6d24822042e4abd7b236ac78..fe5b333220bc73d278f5900adf33808ea467d781 100644 (file)
@@ -99,6 +99,10 @@ class LiveManager {
       }
     })
 
+    // Cleanup broken lives, that were terminated by a server restart for example
+    this.handleBrokenLives()
+      .catch(err => logger.error('Cannot handle broken lives.', { err }))
+
     setInterval(() => this.updateLiveViews(), VIEW_LIFETIME.LIVE)
   }
 
@@ -468,6 +472,14 @@ class LiveManager {
     }
   }
 
+  private async handleBrokenLives () {
+    const videoIds = await VideoModel.listPublishedLiveIds()
+
+    for (const id of videoIds) {
+      await this.onEndTransmuxing(id, true)
+    }
+  }
+
   static get Instance () {
     return this.instance || (this.instance = new this())
   }