Skip to content

Commit

Permalink
remove manager tcp server
Browse files Browse the repository at this point in the history
  • Loading branch information
dasbd72 committed Sep 24, 2023
1 parent 82177fb commit 3a33da1
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 73 deletions.
61 changes: 0 additions & 61 deletions manager-go/cmd/manager/manager.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package main

import (
"bufio"
"encoding/json"
"log"
"net"
"os"
"syscall"

Expand All @@ -24,75 +21,17 @@ type Response struct {

var (
storagePath string
hostIP string
managerPort string
)

func init() {
// read storage path from environment variable
storagePath = os.Getenv("STORAGE_PATH")

// read host ip from environment variable
hostIP = os.Getenv("HOST_IP")
managerPort = os.Getenv("MANAGER_PORT")
// write manager ip to storage
f, err := os.Create(storagePath + "/MANAGER_IP")
if err != nil {
panic(err)
}
log.Println("HOST IP: " + hostIP)
log.Println("MANAGER PORT: " + managerPort)
f.WriteString(hostIP)
f.Close()
}

func main() {
go handleConnections()
handleFileEvents()
}

func handleConnections() {
listener, err := net.Listen("tcp", ":"+managerPort)
if err != nil {
log.Fatal(err)
}
defer listener.Close()

log.Println("Manager is running on " + hostIP + ":" + managerPort)

for {
conn, err := listener.Accept()
if err != nil {
log.Println("[Error] listener.Accept(): ", err)
continue
}

go handleConnection(conn)
}

}

func handleConnection(conn net.Conn) {
reader := bufio.NewReader(conn)
for {
var req Request
var res Response
// Read the request
err := json.NewDecoder(reader).Decode(&req)
if err != nil {
log.Println(err)
break
}

// Handle the request
switch req.Type {
}

// Write the response
json.NewEncoder(conn).Encode(res)
}
}

func handleFileEvents() {
// initialize watcher
watcher, err := rfsnotify.NewWatcher()
Expand Down
6 changes: 0 additions & 6 deletions yamls/manager-disk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ spec:
env:
- name: STORAGE_PATH
value: /shared
- name: HOST_IP
valueFrom:
fieldRef:
fieldPath: status.hostIP
- name: MANAGER_PORT
value: "12346"
volumes:
- name: shared-volume
hostPath:
Expand Down
6 changes: 0 additions & 6 deletions yamls/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@ spec:
env:
- name: STORAGE_PATH
value: /shared
- name: HOST_IP
valueFrom:
fieldRef:
fieldPath: status.hostIP
- name: MANAGER_PORT
value: "12345"
volumes:
- name: shared-volume
hostPath:
Expand Down

0 comments on commit 3a33da1

Please sign in to comment.