fix pidfile, pid is num use '/proc + string(pid)' can't found it
| ... | ... |
@@ -9,6 +9,7 @@ import ( |
| 9 | 9 |
"os" |
| 10 | 10 |
"path/filepath" |
| 11 | 11 |
"strconv" |
| 12 |
+ "strings" |
|
| 12 | 13 |
) |
| 13 | 14 |
|
| 14 | 15 |
// PIDFile is a file used to store the process ID of a running process. |
| ... | ... |
@@ -17,9 +18,10 @@ type PIDFile struct {
|
| 17 | 17 |
} |
| 18 | 18 |
|
| 19 | 19 |
func checkPIDFileAlreadyExists(path string) error {
|
| 20 |
- if pidString, err := ioutil.ReadFile(path); err == nil {
|
|
| 21 |
- if pid, err := strconv.Atoi(string(pidString)); err == nil {
|
|
| 22 |
- if _, err := os.Stat(filepath.Join("/proc", string(pid))); err == nil {
|
|
| 20 |
+ if pidByte, err := ioutil.ReadFile(path); err == nil {
|
|
| 21 |
+ pidString := strings.TrimSpace(string(pidByte)) |
|
| 22 |
+ if pid, err := strconv.Atoi(pidString); err == nil {
|
|
| 23 |
+ if _, err := os.Stat(filepath.Join("/proc", strconv.Itoa(pid))); err == nil {
|
|
| 23 | 24 |
return fmt.Errorf("pid file found, ensure docker is not running or delete %s", path)
|
| 24 | 25 |
} |
| 25 | 26 |
} |