Example #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
}
Example #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
}
Example #3
0
// control starts an HTTP server to handle control RPC via a TCP socket. This
// interface is used to control the Seesaw Node via the CLI or web console.
func (e *ECU) control() {
	tlsConfig, err := e.controlTLSConfig()
	if err != nil {
		log.Errorf("Disabling ECU control server: %v", err)
		<-e.shutdownControl
		e.shutdownControl <- true
		return
	}

	ln, err := net.Listen("tcp", e.cfg.ControlAddress)
	if err != nil {
		log.Fatal("listen error:", err)
	}

	seesawRPC := rpc.NewServer()
	seesawRPC.Register(&SeesawECU{e})
	tlsListener := tls.NewListener(ln, tlsConfig)
	go server.RPCAccept(tlsListener, seesawRPC)

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