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" {
|
if runtime.GOOS != "windows" {
|
||||||
diskstauts = disk.DiskUsage("/grdata")
|
diskstauts = disk.DiskUsage("/grdata")
|
||||||
} else {
|
} else {
|
||||||
diskstauts = disk.DiskUsage(`c:\\grdata`)
|
diskstauts = disk.DiskUsage(`z:\\`)
|
||||||
}
|
}
|
||||||
podMemRequestMB := memR / 1024 / 1024
|
podMemRequestMB := memR / 1024 / 1024
|
||||||
result := &model.ClusterResource{
|
result := &model.ClusterResource{
|
||||||
|
@ -109,30 +109,30 @@ func Routers(mode string) *chi.Mux {
|
|||||||
//TODO:
|
//TODO:
|
||||||
//任务执行框架相关API
|
//任务执行框架相关API
|
||||||
//任务
|
//任务
|
||||||
r.Route("/tasks", func(r chi.Router) {
|
// r.Route("/tasks", func(r chi.Router) {
|
||||||
r.Post("/", controller.CreateTask)
|
// r.Post("/", controller.CreateTask)
|
||||||
r.Get("/", controller.GetTasks)
|
// r.Get("/", controller.GetTasks)
|
||||||
r.Get("/{task_id}", controller.GetTask)
|
// r.Get("/{task_id}", controller.GetTask)
|
||||||
r.Delete("/{task_id}", controller.DeleteTask)
|
// r.Delete("/{task_id}", controller.DeleteTask)
|
||||||
r.Post("/{task_id}/exec", controller.ExecTask)
|
// r.Post("/{task_id}/exec", controller.ExecTask)
|
||||||
r.Get("/{task_id}/status", controller.GetTaskStatus)
|
// r.Get("/{task_id}/status", controller.GetTaskStatus)
|
||||||
})
|
// })
|
||||||
//任务模版
|
// //任务模版
|
||||||
r.Route("/tasktemps", func(r chi.Router) {
|
// r.Route("/tasktemps", func(r chi.Router) {
|
||||||
r.Post("/", controller.CreateTaskTemp)
|
// r.Post("/", controller.CreateTaskTemp)
|
||||||
r.Put("/{temp_id}", controller.UpdateTaskTemp)
|
// r.Put("/{temp_id}", controller.UpdateTaskTemp)
|
||||||
r.Delete("/{temp_id}", controller.DeleteTaskTemp)
|
// r.Delete("/{temp_id}", controller.DeleteTaskTemp)
|
||||||
})
|
// })
|
||||||
//任务组
|
// //任务组
|
||||||
r.Route("/taskgroups", func(r chi.Router) {
|
// r.Route("/taskgroups", func(r chi.Router) {
|
||||||
r.Post("/", controller.CreateTaskGroup)
|
// r.Post("/", controller.CreateTaskGroup)
|
||||||
r.Get("/", controller.GetTaskGroups)
|
// r.Get("/", controller.GetTaskGroups)
|
||||||
r.Get("/{group_id}", controller.GetTaskGroup)
|
// r.Get("/{group_id}", controller.GetTaskGroup)
|
||||||
r.Delete("/{group_id}", controller.DeleteTaskGroup)
|
// r.Delete("/{group_id}", controller.DeleteTaskGroup)
|
||||||
r.Post("/{group_id}/exec", controller.ExecTaskGroup)
|
// r.Post("/{group_id}/exec", controller.ExecTaskGroup)
|
||||||
r.Get("/{group_id}/status", controller.GetTaskGroupStatus)
|
// r.Get("/{group_id}/status", controller.GetTaskGroupStatus)
|
||||||
})
|
// })
|
||||||
r.Put("/tasks/taskreload", controller.ReloadStaticTasks)
|
// r.Put("/tasks/taskreload", controller.ReloadStaticTasks)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return r
|
return r
|
||||||
|
@ -30,6 +30,7 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@ -194,11 +195,15 @@ func CmdRunWithTimeout(cmd *exec.Cmd, timeout time.Duration) (bool, error) {
|
|||||||
//ID是节点的唯一标识,acp_node将把ID与机器信息的绑定关系维护于etcd中
|
//ID是节点的唯一标识,acp_node将把ID与机器信息的绑定关系维护于etcd中
|
||||||
func ReadHostID(filePath string) (string, error) {
|
func ReadHostID(filePath string) (string, error) {
|
||||||
if filePath == "" {
|
if filePath == "" {
|
||||||
filePath = "/opt/rainbond/etc/node/node_host_uuid.conf"
|
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)
|
_, err := os.Stat(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if strings.HasSuffix(err.Error(), "no such file or directory") {
|
if os.IsNotExist(err) {
|
||||||
uid, err := CreateHostID()
|
uid, err := CreateHostID()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
package disk
|
package disk
|
||||||
|
|
||||||
// disk usage of path/disk
|
//DiskUsage disk usage of path/disk
|
||||||
func DiskUsage(path string) (disk Status) {
|
func DiskUsage(path string) (disk Status) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,24 @@
|
|||||||
|
|
||||||
package disk
|
package disk
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
// disk usage of path/disk
|
// disk usage of path/disk
|
||||||
func DiskUsage(path string) (disk Status) {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user