siemonster :: improve determining self container id

This commit is contained in:
Harduino
2020-08-05 12:01:37 +03:00
parent d4a82713db
commit 4135f33982
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -87,7 +87,7 @@ func getThisContainerId() string {
} }
if fCol != "" { if fCol != "" {
cmd := fmt.Sprintf("head -1 /proc/self/cgroup | cut -d/ -f%s", fCol) cmd := fmt.Sprintf("cat /proc/self/cgroup | grep memory | tail -1 | cut -d/ -f%s", fCol)
out, err := exec.Command("bash","-c",cmd).Output() out, err := exec.Command("bash","-c",cmd).Output()
if err == nil { if err == nil {
containerId = strings.TrimSpace(string(out)) containerId = strings.TrimSpace(string(out))
+1 -1
View File
@@ -415,7 +415,7 @@ func shutdown(executionId, workflowId string) {
// form container id of current running container // form container id of current running container
func getThisContainerId() string { func getThisContainerId() string {
containerId := "" containerId := ""
cmd := fmt.Sprintf("head -1 /proc/self/cgroup | cut -d/ -f3") cmd := fmt.Sprintf("cat /proc/self/cgroup | grep memory | tail -1 | cut -d/ -f3")
out, err := exec.Command("bash","-c",cmd).Output() out, err := exec.Command("bash","-c",cmd).Output()
if err == nil { if err == nil {
containerId = strings.TrimSpace(string(out)) containerId = strings.TrimSpace(string(out))