-
Notifications
You must be signed in to change notification settings - Fork 6
/
start.go
45 lines (38 loc) · 986 Bytes
/
start.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package main
import (
"fmt"
"github.com/opencontainers/runtime-spec/specs-go"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
"os"
"syscall"
)
var startCommand = cli.Command{
Name: "start",
ArgsUsage: `<container-id>`,
Flags: []cli.Flag{},
Action: func(context *cli.Context) error {
args := context.Args()
if args.Present() == false {
return fmt.Errorf("Missing container ID")
}
container := context.Args().Get(0)
resumeUkontainer(context, container)
saveState(specs.StateRunning, container, context)
return nil
},
}
func resumeUkontainer(context *cli.Context, container string) error {
// wake the process
pidI, err := readPidFile(context, pidFilePriv)
if err != nil {
return fmt.Errorf("couldn't find pid %d", pidI)
}
proc, err := os.FindProcess(pidI)
if err != nil {
return fmt.Errorf("couldn't find pid %d", pidI)
}
logrus.Debugf("proc %p, pid=%d", proc, pidI)
proc.Signal(syscall.Signal(syscall.SIGCONT))
return nil
}