Skip to content

Commit

Permalink
enable socket communication also for GPU plugin
Browse files Browse the repository at this point in the history
Signed-off-by: Diego Ciangottini <diego.ciangottini@pg.infn.it>
  • Loading branch information
dciangot committed Oct 16, 2024
1 parent 9c35bae commit d875119
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
31 changes: 30 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,36 @@ func main() {
mutex.HandleFunc("/create", SidecarAPIs.CreateHandler)
mutex.HandleFunc("/delete", SidecarAPIs.DeleteHandler)
mutex.HandleFunc("/getLogs", SidecarAPIs.GetLogsHandler)
err = http.ListenAndServe(":"+interLinkConfig.Sidecarport, mutex)

if strings.HasPrefix(interLinkConfig.Socket, "unix://") {
// Create a Unix domain socket and listen for incoming connections.
socket, err := net.Listen("unix", strings.ReplaceAll(interLinkConfig.Socket, "unix://", ""))
if err != nil {
panic(err)
}

// Cleanup the sockfile.
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
go func() {
<-c
os.Remove(strings.ReplaceAll(interLinkConfig.Socket, "unix://", ""))
os.Exit(1)
}()
server := http.Server{
Handler: mutex,
}

log.G(Ctx).Info(socket)

if err := server.Serve(socket); err != nil {
log.G(Ctx).Fatal(err)
}
} else {
err = http.ListenAndServe(":"+interLinkConfig.Sidecarport, mutex)
if err != nil {
log.G(Ctx).Fatal(err)
}

if err != nil {
log.G(Ctx).Fatal(err)
Expand Down
1 change: 1 addition & 0 deletions pkg/common/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type InterLinkConfig struct {
Scancelpath string `yaml:"ScancelPath"`
Squeuepath string `yaml:"SqueuePath"`
Interlinkport string `yaml:"InterlinkPort"`
Socket string `yaml:"Socket"`
Sidecarport string `yaml:"SidecarPort"`
Commandprefix string `yaml:"CommandPrefix"`
ExportPodData bool `yaml:"ExportPodData"`
Expand Down

0 comments on commit d875119

Please sign in to comment.