mirror of
https://github.com/newnius/YAO-scheduler.git
synced 2025-12-12 23:36:44 +00:00
add dockerfile
This commit is contained in:
10
Dockerfile
Normal file
10
Dockerfile
Normal file
@@ -0,0 +1,10 @@
|
||||
FROM ubuntu:16.04
|
||||
|
||||
RUN apt update && \
|
||||
apt install -y wget
|
||||
|
||||
RUN wget https://dl.google.com/go/go1.12.4.linux-amd64.tar.gz && \
|
||||
tar -C /usr/local -xzf go1.12.4.linux-amd64.tar.gz && \
|
||||
rm go1.12.4.linux-amd64.tar.gz
|
||||
|
||||
ENV PATH $PATH:/usr/local/go/bin
|
||||
@@ -12,7 +12,7 @@ var (
|
||||
)
|
||||
|
||||
func start(pool *ResourcePool) {
|
||||
consumer, err := sarama.NewConsumer([]string{"kafka_node1:9091", "kafka_node2:9092", "kafka_node3:9093"}, nil)
|
||||
consumer, err := sarama.NewConsumer([]string{"kafka:9092"}, nil)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@@ -49,11 +49,11 @@ func (jm *JobManager) start() {
|
||||
v.Set("workspace", jm.job.Workspace)
|
||||
v.Set("gpus", strings.Join(GPUs, ","))
|
||||
|
||||
fmt.Print(v.Encode())
|
||||
fmt.Println(v.Encode())
|
||||
|
||||
resp, err := doRequest("POST", "http://kafka_node1:8000/create", strings.NewReader(v.Encode()), "application/x-www-form-urlencoded", "")
|
||||
resp, err := doRequest("POST", "http://kafka:8000/create", strings.NewReader(v.Encode()), "application/x-www-form-urlencoded", "")
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
log.Println(err.Error())
|
||||
return
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
11
src/main.go
11
src/main.go
@@ -37,14 +37,15 @@ func serverAPI(w http.ResponseWriter, r *http.Request) {
|
||||
case "job_submit":
|
||||
var job Job
|
||||
fmt.Println("job_submit")
|
||||
msgSubmit := MsgSubmit{Code: 0}
|
||||
err := json.Unmarshal([]byte(string(r.PostFormValue("job"))), &job)
|
||||
if err != nil {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.Write([]byte(err.Error()))
|
||||
return
|
||||
msgSubmit.Code = 1
|
||||
msgSubmit.Error = err.Error()
|
||||
} else {
|
||||
allocator.schedule(job)
|
||||
}
|
||||
allocator.schedule(job)
|
||||
js, _ := json.Marshal(nodes)
|
||||
js, _ := json.Marshal(msgSubmit)
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.Write(js)
|
||||
break
|
||||
|
||||
@@ -92,8 +92,9 @@ type NodeStatus struct {
|
||||
}
|
||||
|
||||
type MsgAgent struct {
|
||||
ClientID int `json:"code"`
|
||||
Status []NodeStatus `json:"status"`
|
||||
ClientID int `json:"code"`
|
||||
ClientHost string `json:"host"`
|
||||
Status []NodeStatus `json:"status"`
|
||||
}
|
||||
|
||||
type Job struct {
|
||||
|
||||
Reference in New Issue
Block a user