Merge branch 'master' into def/add_users_repositories

This commit is contained in:
def 2024-12-11 13:17:52 +02:00
commit 413521463b
5 changed files with 10 additions and 13 deletions

View file

@ -50,6 +50,7 @@ in
]; ];
after = [ "network-online.target" ]; after = [ "network-online.target" ];
wants = [ "network-online.target" ]; wants = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = { serviceConfig = {
User = "root"; User = "root";
ExecStart = "${selfprivacy-graphql-api}/bin/app.py"; ExecStart = "${selfprivacy-graphql-api}/bin/app.py";
@ -84,6 +85,7 @@ in
]; ];
after = [ "network-online.target" ]; after = [ "network-online.target" ];
wants = [ "network-online.target" ]; wants = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = { serviceConfig = {
User = "root"; User = "root";
ExecStart = "${pkgs.python312Packages.huey}/bin/huey_consumer.py selfprivacy_api.task_registry.huey"; ExecStart = "${pkgs.python312Packages.huey}/bin/huey_consumer.py selfprivacy_api.task_registry.huey";
@ -116,7 +118,7 @@ in
ExecStart = '' ExecStart = ''
${nixos-rebuild} switch --flake .#${config-id} ${nixos-rebuild} switch --flake .#${config-id}
''; '';
KillMode = "none"; KillMode = "mixed";
SendSIGKILL = "no"; SendSIGKILL = "no";
}; };
restartIfChanged = false; restartIfChanged = false;
@ -143,7 +145,7 @@ in
ExecStart = '' ExecStart = ''
${nixos-rebuild} switch --flake .#${config-id} ${nixos-rebuild} switch --flake .#${config-id}
''; '';
KillMode = "none"; KillMode = "mixed";
SendSIGKILL = "no"; SendSIGKILL = "no";
}; };
restartIfChanged = false; restartIfChanged = false;
@ -165,7 +167,7 @@ in
ExecStart = '' ExecStart = ''
${nixos-rebuild} switch --rollback --flake .#${config-id} ${nixos-rebuild} switch --rollback --flake .#${config-id}
''; '';
KillMode = "none"; KillMode = "mixed";
SendSIGKILL = "no"; SendSIGKILL = "no";
}; };
restartIfChanged = false; restartIfChanged = false;

View file

@ -258,7 +258,6 @@ class Backups:
Backups._on_new_snapshot_created(service_name, snapshot) Backups._on_new_snapshot_created(service_name, snapshot)
if reason == BackupReason.AUTO: if reason == BackupReason.AUTO:
Backups._prune_auto_snaps(service) Backups._prune_auto_snaps(service)
service.post_restore()
except Exception as error: except Exception as error:
Jobs.update(job, status=JobStatus.ERROR, error=str(error)) Jobs.update(job, status=JobStatus.ERROR, error=str(error))
raise error raise error

View file

@ -181,7 +181,7 @@ def which_snapshots_to_full_restore() -> list[Snapshot]:
autoslice = Backups.last_backup_slice() autoslice = Backups.last_backup_slice()
api_snapshot = None api_snapshot = None
for snap in autoslice: for snap in autoslice:
if snap.service_name == "api": if snap.service_name == ServiceManager.get_id():
api_snapshot = snap api_snapshot = snap
autoslice.remove(snap) autoslice.remove(snap)
if api_snapshot is None: if api_snapshot is None:

View file

@ -234,12 +234,8 @@ class ServiceManager(Service):
@classmethod @classmethod
def pre_backup(cls): def pre_backup(cls):
tempdir = cls.dump_dir() tempdir = cls.dump_dir()
if not path.exists(tempdir): rmtree(join(tempdir), ignore_errors=True)
makedirs(tempdir) makedirs(tempdir)
paths = listdir(tempdir)
for file in paths:
remove(file)
for p in [USERDATA_FILE, SECRETS_FILE, DKIM_DIR]: for p in [USERDATA_FILE, SECRETS_FILE, DKIM_DIR]:
cls.stash_a_path(p) cls.stash_a_path(p)

View file

@ -828,7 +828,7 @@ def test_cache_invalidaton_task(backups, dummy_service):
def test_service_manager_backup_snapshot_persists(backups, generic_userdata, dkim_file): def test_service_manager_backup_snapshot_persists(backups, generic_userdata, dkim_file):
# There was a bug with snapshot disappearance due to post_restore hooks, checking for that # There was a bug with snapshot disappearance due to post_restore hooks, checking for that
manager = ServiceManager.get_service_by_id("api") manager = ServiceManager.get_service_by_id(ServiceManager.get_id())
assert manager is not None assert manager is not None
snapshot = Backups.back_up(manager) snapshot = Backups.back_up(manager)
@ -844,7 +844,7 @@ def test_service_manager_backs_up_without_crashing(
""" """
Service manager is special and needs testing. Service manager is special and needs testing.
""" """
manager = ServiceManager.get_service_by_id("api") manager = ServiceManager.get_service_by_id(ServiceManager.get_id())
assert manager is not None assert manager is not None
snapshot = Backups.back_up(manager) snapshot = Backups.back_up(manager)