mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 07:41:23 +01:00
split some logic out of KeyValueDatabase::load_or_create
This method did _a lot_ of things at the same time. In order to use `KeyValueDatabase` for the migrate-db command, we need to be able to open a db without attempting to apply all the migrations and without spawning a bunch of unrelated background tasks. The state after this refactor is still not great, but it's enough to do a migration tool.
This commit is contained in:
parent
059dfe54e3
commit
279c6472c5
3 changed files with 127 additions and 103 deletions
|
|
@ -70,9 +70,15 @@ pub(crate) async fn run(args: ServeArgs) -> Result<(), error::ServeCommand> {
|
|||
.expect("should be able to increase the soft limit to the hard limit");
|
||||
|
||||
info!("Loading database");
|
||||
KeyValueDatabase::load_or_create(config, reload_handles)
|
||||
.await
|
||||
let db = KeyValueDatabase::load_or_create(config, reload_handles)
|
||||
.map_err(Error::DatabaseError)?;
|
||||
db.apply_migrations().await.map_err(Error::DatabaseError)?;
|
||||
|
||||
info!("Starting background tasks");
|
||||
services().admin.start_handler();
|
||||
services().sending.start_handler();
|
||||
KeyValueDatabase::start_cleanup_task();
|
||||
services().globals.set_emergency_access();
|
||||
|
||||
info!("Starting server");
|
||||
run_server().await?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue