Merge pull request #329 from crosbymichael/oom-nsinit
Add nsinit command to display oom notifications
This commit is contained in:
commit
dd6bc28afb
|
@ -53,11 +53,12 @@ func main() {
|
|||
app.Before = preload
|
||||
|
||||
app.Commands = []cli.Command{
|
||||
configCommand,
|
||||
execCommand,
|
||||
initCommand,
|
||||
statsCommand,
|
||||
configCommand,
|
||||
oomCommand,
|
||||
pauseCommand,
|
||||
statsCommand,
|
||||
unpauseCommand,
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/codegangsta/cli"
|
||||
"github.com/docker/libcontainer"
|
||||
)
|
||||
|
||||
var oomCommand = cli.Command{
|
||||
Name: "oom",
|
||||
Usage: "display oom notifications for a container",
|
||||
Action: oomAction,
|
||||
}
|
||||
|
||||
func oomAction(context *cli.Context) {
|
||||
state, err := libcontainer.GetState(dataPath)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
n, err := libcontainer.NotifyOnOOM(state)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
for _ = range n {
|
||||
log.Printf("OOM notification received")
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue