From 6eda5c42297e95a331394f6e31bc02ed3bd9c18b Mon Sep 17 00:00:00 2001 From: spiral Date: Fri, 7 Jan 2022 14:26:41 -0500 Subject: [PATCH] feat: only run migrations in single-process mode --- PluralKit.Bot/Init.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/PluralKit.Bot/Init.cs b/PluralKit.Bot/Init.cs index e48368ef..b95d56d5 100644 --- a/PluralKit.Bot/Init.cs +++ b/PluralKit.Bot/Init.cs @@ -42,20 +42,22 @@ public class Init opts.DisableTaskUnobservedTaskExceptionCapture(); }); - // "Connect to the database" (ie. set off database migrations and ensure state) - logger.Information("Connecting to database"); - await services.Resolve().ApplyMigrations(); + var config = services.Resolve(); + if (config.Cluster == null) + { + // "Connect to the database" (ie. set off database migrations and ensure state) + logger.Information("Connecting to database"); + await services.Resolve().ApplyMigrations(); + + // if we're running single-process, clear any existing shard status from the database + await services.Resolve().ClearShardStatus(); + } // Init the bot instance itself, register handlers and such to the client before beginning to connect logger.Information("Initializing bot"); var bot = services.Resolve(); bot.Init(); - // if we're running single-process, clear any existing shard status from the database - var config = services.Resolve(); - var repo = services.Resolve(); - if (config.Cluster == null) - await repo.ClearShardStatus(); // Start the Discord shards themselves (handlers already set up) logger.Information("Connecting to Discord");