crashing not allowed
Some checks failed
builder / build (push) Failing after 24s

This commit is contained in:
abs3nt 2024-10-26 19:44:41 -07:00
parent 88af3135fc
commit 785df8ee46
Signed by: abs3nt
GPG Key ID: A7BD96A8BAB04C09

View File

@ -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)
}
}