Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nice in systemd unit is always 5 #229

Open
jee-r opened this issue Jun 18, 2023 · 5 comments
Open

Nice in systemd unit is always 5 #229

jee-r opened this issue Jun 18, 2023 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@jee-r
Copy link

jee-r commented Jun 18, 2023

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/resticprofile-backup@profile-default.service
[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

@creativeprojects
Copy link
Owner

This is right, I can see in systemd that nice is set to a predefined value:

nice := constants.DefaultBackgroundNiceFlag

Thanks for the report 👍🏻

@creativeprojects creativeprojects self-assigned this Jul 3, 2023
@creativeprojects creativeprojects added the bug Something isn't working label Jul 3, 2023
@flolilo
Copy link

flolilo commented Dec 18, 2023

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 bcfaaa7
  • 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.

@scy
Copy link
Contributor

scy commented Mar 13, 2024

will create restic instances with the default niceness

Can confirm, I'm seeing this too.

  • resticprofile version 0.26.0 commit 2ab1f3a
  • 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?

@creativeprojects
Copy link
Owner

creativeprojects commented Mar 13, 2024

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? #339

(This is a fix when running from the terminal, not from systemd)

@flolilo
Copy link

flolilo commented Mar 14, 2024

Hello again!

#339 seems to work for me!

@scy scy mentioned this issue Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants