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"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"runtime/debug"
|
||||
"strconv"
|
||||
"strings"
|
||||
@ -793,7 +794,7 @@ func main() {
|
||||
|
||||
scLock, err := scbase.AcquireWaveLock()
|
||||
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
|
||||
}
|
||||
if len(os.Args) >= 2 && strings.HasPrefix(os.Args[1], "--migrate") {
|
||||
@ -886,4 +887,5 @@ func main() {
|
||||
if err != nil {
|
||||
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)
|
||||
}
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user