MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / loop

Method loop

internal/nodes/task_trim_disks.go:45–73  ·  view source on GitHub ↗

run the task once

()

Source from the content-addressed store, hash-verified

43
44// run the task once
45func (this *TrimDisksTask) loop() error {
46 if runtime.GOOS != "linux" {
47 return nil
48 }
49
50 var nodeConfig = sharedNodeConfig
51 if nodeConfig == nil {
52 return nil
53 }
54 if !nodeConfig.AutoTrimDisks {
55 return nil
56 }
57
58 trimExe, err := executils.LookPath("fstrim")
59 if err != nil {
60 return fmt.Errorf("'fstrim' command not found: %w", err)
61 }
62
63 defer trackers.Begin("TRIM_DISKS").End()
64
65 var cmd = executils.NewCmd(trimExe, "-a").
66 WithStderr()
67 err = cmd.Run()
68 if err != nil {
69 return fmt.Errorf("'fstrim' execute failed: %s", cmd.Stderr())
70 }
71
72 return nil
73}

Callers 1

StartMethod · 0.95

Calls 6

BeginFunction · 0.92
ErrorfMethod · 0.80
WithStderrMethod · 0.80
StderrMethod · 0.80
EndMethod · 0.45
RunMethod · 0.45

Tested by

no test coverage detected