34 lines
1.0 KiB
Go
34 lines
1.0 KiB
Go
package models
|
|
|
|
import (
|
|
"main/configs"
|
|
"time"
|
|
)
|
|
|
|
type Server struct {
|
|
ID int `json:"id" gorm:"primary_key"`
|
|
Name string `json:"name"`
|
|
Type string `json:"type"` // (訓練|推理)
|
|
IP string `json:"ip"`
|
|
Port int `json:"port"`
|
|
Status string `json:"status"` // (異常|初始化|閒置|就緒|工作中|關閉中)
|
|
UserName string `json:"username"`
|
|
Password string `json:"password"`
|
|
Models []map[string]interface{} `json:"models" gorm:"-"` // 數據庫不必保存
|
|
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"`
|
|
UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"`
|
|
}
|
|
|
|
func init() {
|
|
configs.ORMDB().AutoMigrate(&Server{})
|
|
|
|
// 添加一個預設的訓練機
|
|
configs.ORMDB().Create(&Server{
|
|
Name: "GPU T4",
|
|
Type: "train",
|
|
IP: "106.15.192.42",
|
|
Port: 7860,
|
|
Status: "閒置",
|
|
})
|
|
}
|