|
|
@@ -16,6 +16,7 @@ package main
|
|
|
|
|
|
import (
|
|
|
"fmt"
|
|
|
+ "log"
|
|
|
"net"
|
|
|
"os"
|
|
|
"os/exec"
|
|
|
@@ -119,7 +120,17 @@ func (a *Agent) cleanup() error {
|
|
|
}
|
|
|
f, err := os.Create(a.etcdLogPath)
|
|
|
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
|