debug
This commit is contained in:
@@ -9,10 +9,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// 設置日誌顯示文件名和行號
|
|
||||||
log.SetFlags(log.Lshortfile | log.LstdFlags)
|
|
||||||
|
|
||||||
// 原生golang 創建 data 目錄不存在則創建
|
|
||||||
if _, err := os.Stat("data"); os.IsNotExist(err) {
|
if _, err := os.Stat("data"); os.IsNotExist(err) {
|
||||||
os.Mkdir("data", os.ModePerm)
|
os.Mkdir("data", os.ModePerm)
|
||||||
}
|
}
|
||||||
|
1
main.go
1
main.go
@@ -16,6 +16,7 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||||
|
log.SetFlags(log.Lshortfile | log.LstdFlags)
|
||||||
|
|
||||||
r := mux.NewRouter()
|
r := mux.NewRouter()
|
||||||
|
|
||||||
|
@@ -105,8 +105,9 @@ func ModelItemGet(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
func ModelItemPatch(w http.ResponseWriter, r *http.Request) {
|
func ModelItemPatch(w http.ResponseWriter, r *http.Request) {
|
||||||
var model = models.Model{ID: utils.ParamInt(mux.Vars(r)["id"], 0)}
|
var model = models.Model{ID: utils.ParamInt(mux.Vars(r)["id"], 0)}
|
||||||
if err := configs.ORMDB().Take(&model, utils.ParamInt(mux.Vars(r)["id"], 0)); err != nil {
|
if err := configs.ORMDB().Take(&model, utils.ParamInt(mux.Vars(r)["id"], 0)).Error; err != nil {
|
||||||
w.WriteHeader(http.StatusNotFound)
|
w.WriteHeader(http.StatusNotFound)
|
||||||
|
w.Write([]byte(err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,9 +134,9 @@ func ModelItemPatch(w http.ResponseWriter, r *http.Request) {
|
|||||||
if model_new.Status != "" && model_new.Status != model.Status {
|
if model_new.Status != "" && model_new.Status != model.Status {
|
||||||
model.Status = model_new.Status
|
model.Status = model_new.Status
|
||||||
// 如果狀態被改變爲 ready, 將模型發送到訓練隊列
|
// 如果狀態被改變爲 ready, 將模型發送到訓練隊列
|
||||||
if model.Status == "ready" {
|
//if model.Status == "ready" {
|
||||||
//model.SendToTrain()
|
// model.SendToTrain()
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
if model_new.Image != "" && model_new.Image != model.Image {
|
if model_new.Image != "" && model_new.Image != model.Image {
|
||||||
model.Image = model_new.Image
|
model.Image = model_new.Image
|
||||||
|
@@ -107,7 +107,7 @@ func SessionsItemGet(w http.ResponseWriter, r *http.Request) {
|
|||||||
// 更新會話
|
// 更新會話
|
||||||
func SessionsItemPatch(w http.ResponseWriter, r *http.Request) {
|
func SessionsItemPatch(w http.ResponseWriter, r *http.Request) {
|
||||||
session := models.Session{ID: mux.Vars(r)["session_id"]}
|
session := models.Session{ID: mux.Vars(r)["session_id"]}
|
||||||
if err := configs.ORMDB().Model(&session).Updates(GetForm(r)); err != nil {
|
if err := configs.ORMDB().Model(&session).Updates(GetForm(r)).Error; err != nil {
|
||||||
w.WriteHeader(http.StatusNotFound)
|
w.WriteHeader(http.StatusNotFound)
|
||||||
w.Write([]byte("404 - Not Found"))
|
w.Write([]byte("404 - Not Found"))
|
||||||
return
|
return
|
||||||
|
Reference in New Issue
Block a user