- Pass --ignore-inode for sources below /mnt/user and /mnt/user0. shfs hands out new inode numbers after every reboot, which made Restic re-read all data on the first run after a restart. - Add a per-job lowPriority option that starts Restic and Rsync through ionice (idle) and nice 19 via the new internal/procprio package. - Run restic forget with --group-by host,tags. Grouping by paths split a job into a new group whenever its sources changed, and keep-within never expired the old group's snapshots. - Verify the Unraid CSRF token in webgui/api.php for POST, PUT and DELETE and reject other methods; Unraid's own check only covers form posts. - Set $urbmVersion in URBM.page during the package build and fail the build if it does not match, so the page always loads the packaged JS asset. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
36 lines
1.2 KiB
Go
36 lines
1.2 KiB
Go
// Package procprio starts helper processes with reduced CPU and IO priority.
|
|
package procprio
|
|
|
|
import "os/exec"
|
|
|
|
// lookPath is replaceable in tests.
|
|
var lookPath = exec.LookPath
|
|
|
|
// Command returns the executable and arguments to run binary with args.
|
|
//
|
|
// With low set, the process is started through ionice (idle IO class) and
|
|
// nice (level 19), so it only receives CPU time and disk bandwidth that no
|
|
// other process on the server needs. Both tools exec the target, so the PID,
|
|
// process group, signals and exit status stay those of binary. A tool that
|
|
// is not installed is skipped; without either tool the command is unchanged.
|
|
func Command(low bool, binary string, args []string) (string, []string) {
|
|
if !low {
|
|
return binary, args
|
|
}
|
|
var prefix []string
|
|
if path, err := lookPath("ionice"); err == nil {
|
|
prefix = append(prefix, path, "-c", "3")
|
|
}
|
|
if path, err := lookPath("nice"); err == nil {
|
|
prefix = append(prefix, path, "-n", "19")
|
|
}
|
|
if len(prefix) == 0 {
|
|
return binary, args
|
|
}
|
|
full := make([]string, 0, len(prefix)+len(args))
|
|
full = append(full, prefix[1:]...)
|
|
full = append(full, binary)
|
|
full = append(full, args...)
|
|
return prefix[0], full
|
|
}
|