github.com/apptainer/singularity@v3.1.1+incompatible/internal/app/starter/rpc.go (about)

     1  // Copyright (c) 2018, Sylabs Inc. All rights reserved.
     2  // This software is licensed under a 3-clause BSD license. Please consult the
     3  // LICENSE.md file distributed with the sources of this project regarding your
     4  // rights to use or distribute this software.
     5  
     6  package starter
     7  
     8  import (
     9  	"net"
    10  	"os"
    11  
    12  	"github.com/sylabs/singularity/internal/pkg/runtime/engines"
    13  	"github.com/sylabs/singularity/internal/pkg/sylog"
    14  )
    15  
    16  // RPCServer serves runtime engine requests
    17  func RPCServer(socket int, name string) {
    18  	comm := os.NewFile(uintptr(socket), "unix")
    19  	conn, err := net.FileConn(comm)
    20  	if err != nil {
    21  		sylog.Fatalf("socket communication error: %s\n", err)
    22  	}
    23  	comm.Close()
    24  	engines.ServeRuntimeEngineRequests(name, conn)
    25  
    26  	os.Exit(0)
    27  }