etcd-agent: cleans page cache when cleaning up
Reference: - https://www.kernel.org/doc/Documentation/sysctl/vm.txt - https://github.com/torvalds/linux/blob/master/fs/drop_caches.crelease-2.3
parent
fcf94f3a59
commit
78df258ea8
|
@ -16,6 +16,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
@ -119,7 +120,17 @@ func (a *Agent) cleanup() error {
|
||||||
}
|
}
|
||||||
f, err := os.Create(a.etcdLogPath)
|
f, err := os.Create(a.etcdLogPath)
|
||||||
a.logfile = f
|
a.logfile = f
|
||||||
return err
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://www.kernel.org/doc/Documentation/sysctl/vm.txt
|
||||||
|
// https://github.com/torvalds/linux/blob/master/fs/drop_caches.c
|
||||||
|
cmd := exec.Command("/bin/sh", "-c", `echo "echo 1 > /proc/sys/vm/drop_caches" | sudo sh`)
|
||||||
|
if err := cmd.Run(); err != nil {
|
||||||
|
log.Printf("error when cleaning page cache (%v)", err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// terminate stops the exiting etcd process the agent started
|
// terminate stops the exiting etcd process the agent started
|
||||||
|
|
Loading…
Reference in New Issue