This commit is contained in:
parent
88af3135fc
commit
785df8ee46
@ -5,6 +5,7 @@ import (
|
||||
"net"
|
||||
"net/rpc"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"go.uber.org/fx"
|
||||
|
||||
@ -13,6 +14,14 @@ import (
|
||||
)
|
||||
|
||||
func Run(c *commands.Commander, conf *config.Config, s fx.Shutdowner) {
|
||||
for {
|
||||
func() {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
log.Printf("Recovered in Run: %v", r)
|
||||
}
|
||||
}()
|
||||
|
||||
socketPath := conf.SocketPath
|
||||
if _, err := os.Stat(socketPath); err == nil {
|
||||
os.Remove(socketPath)
|
||||
@ -27,7 +36,9 @@ func Run(c *commands.Commander, conf *config.Config, s fx.Shutdowner) {
|
||||
|
||||
listener, err := net.Listen("unix", socketPath)
|
||||
if err != nil {
|
||||
log.Fatal("Listen error:", err)
|
||||
log.Println("Listen error:", err)
|
||||
time.Sleep(time.Second)
|
||||
return
|
||||
}
|
||||
defer listener.Close()
|
||||
os.Chmod(socketPath, 0o666)
|
||||
@ -41,6 +52,16 @@ func Run(c *commands.Commander, conf *config.Config, s fx.Shutdowner) {
|
||||
continue
|
||||
}
|
||||
codec := NewLoggingServerCodec(conn)
|
||||
go server.ServeCodec(codec)
|
||||
go func() {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
log.Printf("Recovered in ServeCodec goroutine: %v", r)
|
||||
}
|
||||
}()
|
||||
server.ServeCodec(codec)
|
||||
}()
|
||||
}
|
||||
}()
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user