Implement autosaving of data held in memory

Add controller.autosave_interval config that specifies the frequency
which controller config, hosts, instances, users, mod packs and plugin
specific data which is held in memory should be automatically flushed to
disk if they have changed since the last time they were saved.  This
prevents data loss in the event of a server crash.

Plugins can use the onSaveData hook to save its own data at the same
time as the controller does and this obsoletes making an autosave
interval in the plugin.

Resolves #523.
This commit is contained in:
Hornwitser committed 2023-11-29 20:18:50 +01:00
1 parent faadf873fb
commit ffe5040644
14 files changed
+168 -57

No files matched your search

@@ -665,6 +665,7 @@ export default class ControlConnection extends BaseConnection {
// Start at 5 to leave space for future default roles
let id = Math.max(5, lastId+1);
this._controller.userManager.roles.set(id, new lib.Role({ id, ...request }));
this._controller.userManager.dirty = true;
return id;
}
@@ -699,6 +700,7 @@ export default class ControlConnection extends BaseConnection {
}
this._controller.userManager.roles.delete(id);
this._controller.userManager.dirty = true;
for (let user of this._controller.userManager.users.values()) {
user.roles.delete(role);
this._controller.userPermissionsUpdated(user);