mirror of
https://github.com/wavetermdev/waveterm.git
synced 2024-12-22 16:48:23 +01:00
gc was collecting the lockfile early causing it not to work. fixed with runtime.KeepAlive
This commit is contained in:
parent
68731f45a2
commit
1a566d06aa
@ -18,6 +18,7 @@ import (
|
|||||||
"os/signal"
|
"os/signal"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"runtime"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -793,7 +794,7 @@ func main() {
|
|||||||
|
|
||||||
scLock, err := scbase.AcquireWaveLock()
|
scLock, err := scbase.AcquireWaveLock()
|
||||||
if err != nil || scLock == nil {
|
if err != nil || scLock == nil {
|
||||||
log.Printf("[error] cannot acquire wave lock: %v\n", err)
|
log.Printf("[error] cannot acquire wave lock (another instance of wavesrv is likely running): %v\n", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(os.Args) >= 2 && strings.HasPrefix(os.Args[1], "--migrate") {
|
if len(os.Args) >= 2 && strings.HasPrefix(os.Args[1], "--migrate") {
|
||||||
@ -886,4 +887,5 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("ERROR: %v\n", err)
|
log.Printf("ERROR: %v\n", err)
|
||||||
}
|
}
|
||||||
|
runtime.KeepAlive(scLock)
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,8 @@ func AcquireWaveLock() (*os.File, error) {
|
|||||||
return nil, fmt.Errorf("cannot find/create WAVETERM_HOME directory %q", homeDir)
|
return nil, fmt.Errorf("cannot find/create WAVETERM_HOME directory %q", homeDir)
|
||||||
}
|
}
|
||||||
lockFileName := path.Join(homeDir, WaveLockFile)
|
lockFileName := path.Join(homeDir, WaveLockFile)
|
||||||
fd, err := os.OpenFile(lockFileName, os.O_WRONLY|os.O_CREATE, 0600)
|
log.Printf("[base] acquiring lock on %s\n", lockFileName)
|
||||||
|
fd, err := os.OpenFile(lockFileName, os.O_RDWR|os.O_CREATE, 0600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user