Ejemplo n.º 1
0
// Run starts the NCC server.
func (n *Server) Run() {
	if err := server.RemoveUnixSocket(n.nccSocket); err != nil {
		log.Fatalf("Failed to remove socket: %v", err)
	}
	ln, err := net.Listen("unix", n.nccSocket)
	if err != nil {
		log.Fatalf("listen error: %v", err)
	}
	defer ln.Close()
	defer os.Remove(n.nccSocket)

	seesawNCC := rpc.NewServer()
	seesawNCC.Register(&SeesawNCC{})
	go server.RPCAccept(ln, seesawNCC)

	<-n.shutdown
}
Ejemplo n.º 2
0
// engineIPC starts an RPC server to handle IPC via a Unix Domain socket.
func (e *Engine) engineIPC() {
	if err := server.RemoveUnixSocket(e.config.SocketPath); err != nil {
		log.Fatalf("Failed to remove socket: %v", err)
	}
	ln, err := net.Listen("unix", e.config.SocketPath)
	if err != nil {
		log.Fatalf("Listen failed: %v", err)
	}
	defer os.Remove(e.config.SocketPath)

	seesawIPC := rpc.NewServer()
	seesawIPC.Register(&SeesawEngine{e})
	go server.RPCAccept(ln, seesawIPC)

	<-e.shutdownIPC
	ln.Close()
	e.shutdownIPC <- true
}