Making it not crash on Windows
Signed-off-by: John Howard <jhoward@microsoft.com>
This commit is contained in:
@@ -1,23 +1,6 @@
|
||||
package supervisor
|
||||
|
||||
import "github.com/cloudfoundry/gosigar"
|
||||
|
||||
type Machine struct {
|
||||
Cpus int
|
||||
Memory int64
|
||||
}
|
||||
|
||||
func CollectMachineInformation() (Machine, error) {
|
||||
m := Machine{}
|
||||
cpu := sigar.CpuList{}
|
||||
if err := cpu.Get(); err != nil {
|
||||
return m, err
|
||||
}
|
||||
m.Cpus = len(cpu.List)
|
||||
mem := sigar.Mem{}
|
||||
if err := mem.Get(); err != nil {
|
||||
return m, err
|
||||
}
|
||||
m.Memory = int64(mem.Total / 1024 / 1024)
|
||||
return m, nil
|
||||
}
|
||||
|
||||
18
supervisor/machine_linux.go
Normal file
18
supervisor/machine_linux.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package supervisor
|
||||
|
||||
import "github.com/cloudfoundry/gosigar"
|
||||
|
||||
func CollectMachineInformation() (Machine, error) {
|
||||
m := Machine{}
|
||||
cpu := sigar.CpuList{}
|
||||
if err := cpu.Get(); err != nil {
|
||||
return m, err
|
||||
}
|
||||
m.Cpus = len(cpu.List)
|
||||
mem := sigar.Mem{}
|
||||
if err := mem.Get(); err != nil {
|
||||
return m, err
|
||||
}
|
||||
m.Memory = int64(mem.Total / 1024 / 1024)
|
||||
return m, nil
|
||||
}
|
||||
5
supervisor/machine_windows.go
Normal file
5
supervisor/machine_windows.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package supervisor
|
||||
|
||||
func CollectMachineInformation() (Machine, error) {
|
||||
return Machine{}, nil
|
||||
}
|
||||
@@ -11,7 +11,8 @@ import (
|
||||
// Linux implementation. @crosbymichael - Help needed.
|
||||
|
||||
func NewMonitor() (*Monitor, error) {
|
||||
return nil, errors.New("NewMonitor not implemented on Windows")
|
||||
// During Windows bring-up, don't error out other binary bombs immediately.
|
||||
return &Monitor{}, nil
|
||||
}
|
||||
|
||||
type Monitor struct {
|
||||
|
||||
Reference in New Issue
Block a user