mirror of
https://github.com/newnius/YAO-scheduler.git
synced 2025-12-15 08:16:43 +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) {
|
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 {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,11 +49,11 @@ func (jm *JobManager) start() {
|
|||||||
v.Set("workspace", jm.job.Workspace)
|
v.Set("workspace", jm.job.Workspace)
|
||||||
v.Set("gpus", strings.Join(GPUs, ","))
|
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 {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
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":
|
case "job_submit":
|
||||||
var job Job
|
var job Job
|
||||||
fmt.Println("job_submit")
|
fmt.Println("job_submit")
|
||||||
|
msgSubmit := MsgSubmit{Code: 0}
|
||||||
err := json.Unmarshal([]byte(string(r.PostFormValue("job"))), &job)
|
err := json.Unmarshal([]byte(string(r.PostFormValue("job"))), &job)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.Header().Set("Content-Type", "application/json")
|
msgSubmit.Code = 1
|
||||||
w.Write([]byte(err.Error()))
|
msgSubmit.Error = err.Error()
|
||||||
return
|
} else {
|
||||||
|
allocator.schedule(job)
|
||||||
}
|
}
|
||||||
allocator.schedule(job)
|
js, _ := json.Marshal(msgSubmit)
|
||||||
js, _ := json.Marshal(nodes)
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
w.Write(js)
|
w.Write(js)
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -92,8 +92,9 @@ type NodeStatus struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type MsgAgent struct {
|
type MsgAgent struct {
|
||||||
ClientID int `json:"code"`
|
ClientID int `json:"code"`
|
||||||
Status []NodeStatus `json:"status"`
|
ClientHost string `json:"host"`
|
||||||
|
Status []NodeStatus `json:"status"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Job struct {
|
type Job struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user