feat: only run migrations in single-process mode

This commit is contained in:
spiral 2022-01-07 14:26:41 -05:00
parent 39c8590bce
commit 6eda5c4229
No known key found for this signature in database
GPG Key ID: A6059F0CA0E1BD31

View File

@ -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<IDatabase>().ApplyMigrations();
var config = services.Resolve<BotConfig>();
if (config.Cluster == null)
{
// "Connect to the database" (ie. set off database migrations and ensure state)
logger.Information("Connecting to database");
await services.Resolve<IDatabase>().ApplyMigrations();
// if we're running single-process, clear any existing shard status from the database
await services.Resolve<ModelRepository>().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>();
bot.Init();
// if we're running single-process, clear any existing shard status from the database
var config = services.Resolve<BotConfig>();
var repo = services.Resolve<ModelRepository>();
if (config.Cluster == null)
await repo.ClearShardStatus();
// Start the Discord shards themselves (handlers already set up)
logger.Information("Connecting to Discord");