Simplify error handling for file lock in tunnel command
parent
d8a920fd39
commit
09e6aff951
|
@ -136,12 +136,11 @@ func mustLockOrExit() {
|
|||
|
||||
_, err := os.OpenFile(tunnelLockPath, os.O_RDWR|os.O_TRUNC, 0600)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
_, err = os.Create(tunnelLockPath)
|
||||
if err != nil {
|
||||
exit.Error(reason.SvcTunnelStart, fmt.Sprintf("error creating lock for tunnel file (%s)", tunnelLockPath), err)
|
||||
}
|
||||
} else {
|
||||
if !os.IsNotExist(err) {
|
||||
exit.Error(reason.SvcTunnelStart, fmt.Sprintf("error opening lock file for tunnel file (%s)", tunnelLockPath), err)
|
||||
}
|
||||
_, err = os.Create(tunnelLockPath)
|
||||
if err != nil {
|
||||
exit.Error(reason.SvcTunnelStart, fmt.Sprintf("error creating lock for tunnel file (%s)", tunnelLockPath), err)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue