resticprofile
resticprofile copied to clipboard
Nice in systemd unit is always 5
Hello
I noticed that nice
in global section is not correctly passed to systemd unit template.
for example with this config
version: "1"
global:
nice: 17
default:
repository: "my_repo"
password-file: "key"
backup:
exclude-file: "excludes"
exclude-caches: true
one-file-system: true
tag:
- "test"
source:
- "/tmp/"
schedule: "*-*-* 12:15:00"
schedule-permission: system
schedule-priority: background
schedule-lock-mode: default
schedule-lock-wait: 15m30s
After running schedule
the systemd unit file is
cat /etc/systemd/system/[email protected]
[Unit]
Description=resticprofile backup for profile default in ./profiles.yaml
[Service]
Type=notify
WorkingDirectory=/tmp
ExecStart=/usr/local/bin/resticprofile --no-prio --no-ansi --config ./profiles.yaml --name default --lock-wait 15m30s backup
Nice=5
Environment="HOME=/root"
Environment="SUDO_USER=test"
Nice is set to 5 and not to 17 as expected
This is right, I can see in systemd
that nice is set to a predefined value:
https://github.com/creativeprojects/resticprofile/blob/3476fbce1425f3368527c05a9130d511fe530139/systemd/generate.go#L121
Thanks for the report 👍🏻
Hello, Just wanted to chime in that when starting resticprofile from the terminal with:
# leaving out definitely unrelated settings, i.e. paths
global:
# neither this:
priority: "idle"
# nor this:
nice: 19
# ...nor both together change anything.
default:
backup:
verbose: 2
also will create restic instances with the default niceness.
-
resticprofile version
: resticprofile version 0.24.0 commit bcfaaa7cacfa7f88a94d5dc62ca69b2d89205d89 -
restic version
: restic 0.16.2 compiled with go1.21.3 on linux/amd64
Edit: resticprofile itself respects the setting, only the restic instances are started at the default niceness.
will create restic instances with the default niceness
Can confirm, I'm seeing this too.
- resticprofile version 0.26.0 commit 2ab1f3a38467114aeb4095c0924817b369280e39
- restic 0.16.4 compiled with go1.21.6 on linux/amd64
- Linux 6.1.0-17-amd64 SMP PREEMPT_DYNAMIC Debian 6.1.69-1 (2023-12-30) x86_64 (bookworm)
Now, I'm no Go programmer, and only somewhat familiar with the Unix/Linux API, but it looks to me as if you're creating a process group, but then setting the niceness only for the current process and not the group in https://github.com/creativeprojects/resticprofile/blob/master/priority/linux.go#L52-L60:
err = unix.Setpriority(unix.PRIO_PROCESS, pid, priority)
Could using PRIO_PGRP
instead of PRIO_PROCESS
be enough to fix that?
Could using PRIO_PGRP instead of PRIO_PROCESS be enough to fix that?
Well spotted!
If you guys are ok with compiling go code, can you try again with this MR? https://github.com/creativeprojects/resticprofile/pull/339
(This is a fix when running from the terminal, not from systemd
)
Hello again!
#339 seems to work for me!