mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-12-02 03:37:46 +08:00
[FIX] fix hostid file can not create bug in windows and hide task api
This commit is contained in:
parent
7985b67820
commit
71e9552e3d
@ -343,7 +343,7 @@ func ClusterInfo(w http.ResponseWriter, r *http.Request) {
|
||||
if runtime.GOOS != "windows" {
|
||||
diskstauts = disk.DiskUsage("/grdata")
|
||||
} else {
|
||||
diskstauts = disk.DiskUsage(`c:\\grdata`)
|
||||
diskstauts = disk.DiskUsage(`z:\\`)
|
||||
}
|
||||
podMemRequestMB := memR / 1024 / 1024
|
||||
result := &model.ClusterResource{
|
||||
|
@ -109,30 +109,30 @@ func Routers(mode string) *chi.Mux {
|
||||
//TODO:
|
||||
//任务执行框架相关API
|
||||
//任务
|
||||
r.Route("/tasks", func(r chi.Router) {
|
||||
r.Post("/", controller.CreateTask)
|
||||
r.Get("/", controller.GetTasks)
|
||||
r.Get("/{task_id}", controller.GetTask)
|
||||
r.Delete("/{task_id}", controller.DeleteTask)
|
||||
r.Post("/{task_id}/exec", controller.ExecTask)
|
||||
r.Get("/{task_id}/status", controller.GetTaskStatus)
|
||||
})
|
||||
//任务模版
|
||||
r.Route("/tasktemps", func(r chi.Router) {
|
||||
r.Post("/", controller.CreateTaskTemp)
|
||||
r.Put("/{temp_id}", controller.UpdateTaskTemp)
|
||||
r.Delete("/{temp_id}", controller.DeleteTaskTemp)
|
||||
})
|
||||
//任务组
|
||||
r.Route("/taskgroups", func(r chi.Router) {
|
||||
r.Post("/", controller.CreateTaskGroup)
|
||||
r.Get("/", controller.GetTaskGroups)
|
||||
r.Get("/{group_id}", controller.GetTaskGroup)
|
||||
r.Delete("/{group_id}", controller.DeleteTaskGroup)
|
||||
r.Post("/{group_id}/exec", controller.ExecTaskGroup)
|
||||
r.Get("/{group_id}/status", controller.GetTaskGroupStatus)
|
||||
})
|
||||
r.Put("/tasks/taskreload", controller.ReloadStaticTasks)
|
||||
// r.Route("/tasks", func(r chi.Router) {
|
||||
// r.Post("/", controller.CreateTask)
|
||||
// r.Get("/", controller.GetTasks)
|
||||
// r.Get("/{task_id}", controller.GetTask)
|
||||
// r.Delete("/{task_id}", controller.DeleteTask)
|
||||
// r.Post("/{task_id}/exec", controller.ExecTask)
|
||||
// r.Get("/{task_id}/status", controller.GetTaskStatus)
|
||||
// })
|
||||
// //任务模版
|
||||
// r.Route("/tasktemps", func(r chi.Router) {
|
||||
// r.Post("/", controller.CreateTaskTemp)
|
||||
// r.Put("/{temp_id}", controller.UpdateTaskTemp)
|
||||
// r.Delete("/{temp_id}", controller.DeleteTaskTemp)
|
||||
// })
|
||||
// //任务组
|
||||
// r.Route("/taskgroups", func(r chi.Router) {
|
||||
// r.Post("/", controller.CreateTaskGroup)
|
||||
// r.Get("/", controller.GetTaskGroups)
|
||||
// r.Get("/{group_id}", controller.GetTaskGroup)
|
||||
// r.Delete("/{group_id}", controller.DeleteTaskGroup)
|
||||
// r.Post("/{group_id}/exec", controller.ExecTaskGroup)
|
||||
// r.Get("/{group_id}/status", controller.GetTaskGroupStatus)
|
||||
// })
|
||||
// r.Put("/tasks/taskreload", controller.ReloadStaticTasks)
|
||||
}
|
||||
})
|
||||
return r
|
||||
|
@ -30,6 +30,7 @@ import (
|
||||
"path"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
@ -194,11 +195,15 @@ func CmdRunWithTimeout(cmd *exec.Cmd, timeout time.Duration) (bool, error) {
|
||||
//ID是节点的唯一标识,acp_node将把ID与机器信息的绑定关系维护于etcd中
|
||||
func ReadHostID(filePath string) (string, error) {
|
||||
if filePath == "" {
|
||||
if runtime.GOOS == "windows" {
|
||||
filePath = "c:\\rainbond\\node_host_uuid.conf"
|
||||
} else {
|
||||
filePath = "/opt/rainbond/etc/node/node_host_uuid.conf"
|
||||
}
|
||||
}
|
||||
_, err := os.Stat(filePath)
|
||||
if err != nil {
|
||||
if strings.HasSuffix(err.Error(), "no such file or directory") {
|
||||
if os.IsNotExist(err) {
|
||||
uid, err := CreateHostID()
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
package disk
|
||||
|
||||
// disk usage of path/disk
|
||||
//DiskUsage disk usage of path/disk
|
||||
func DiskUsage(path string) (disk Status) {
|
||||
return
|
||||
}
|
||||
|
@ -18,7 +18,24 @@
|
||||
|
||||
package disk
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// disk usage of path/disk
|
||||
func DiskUsage(path string) (disk Status) {
|
||||
h := syscall.MustLoadDLL("kernel32.dll")
|
||||
c := h.MustFindProc("GetDiskFreeSpaceExW")
|
||||
lpFreeBytesAvailable := int64(0)
|
||||
lpTotalNumberOfBytes := int64(0)
|
||||
lpTotalNumberOfFreeBytes := int64(0)
|
||||
r2, _, err := c.Call(uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr("F:"))),
|
||||
uintptr(unsafe.Pointer(&lpFreeBytesAvailable)),
|
||||
uintptr(unsafe.Pointer(&lpTotalNumberOfBytes)),
|
||||
uintptr(unsafe.Pointer(&lpTotalNumberOfFreeBytes)))
|
||||
disk.All = uint64(lpTotalNumberOfBytes)
|
||||
disk.Free = uint64(lpTotalNumberOfFreeBytes)
|
||||
disk.Used = uint64(lpTotalNumberOfBytes - lpTotalNumberOfFreeBytes)
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user