-
Notifications
You must be signed in to change notification settings - Fork 1
/
funcContainerStartAfterBuild.go
81 lines (75 loc) · 2.28 KB
/
funcContainerStartAfterBuild.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package iotmakerdockerbuilder
import (
"github.com/helmutkemper/util"
"log"
"time"
)
// ContainerStartAfterBuild
//
// English:
//
// Starts a newly created container.
//
// Output:
// err: standard error object
//
// Note:
//
// * There are two ways to create a container:
// ContainerBuildAndStartFromImage, initializes the oncontainer and initializes the registry to
// the docker network, so that it works correctly.
// ContainerBuildWithoutStartingItFromImage just creates the container, so the first time it runs
// it must have its network registry initialized so it can work properly.
// * After initializing the first time, use the functions, ContainerStart, ContainerPause and
// ContainerStop, in case you need to control the container.
//
// Português:
//
// Inicia um container recem criado.
//
// Saída:
// err: Objeto de erro padrão
//
// Nota:
//
// * Ha duas formas de criar um container:
// ContainerBuildAndStartFromImage, inicializa o oncontainer e inicializa o registro aa rede
// docker, para que o mesmo funcione de forma correta.
// ContainerBuildWithoutStartingItFromImage apenas cria o container, por isto, a primeira vez que
// o mesmo roda, ele deve ter o seu registro de rede inicializado para que possa funcionar de
// forma correta.
// * Apos inicializado a primeira vez, use as funções, ContainerStart, ContainerPause e
// ContainerStop, caso necessite controlar o container.
func (e *ContainerBuilder) ContainerStartAfterBuild() (err error) {
err = e.dockerSys.ContainerStart(e.containerID)
if err != nil {
util.TraceToLog()
return
}
if e.waitString != "" && e.waitStringTimeout == 0 {
_, err = e.dockerSys.ContainerLogsWaitText(e.containerID, e.waitString, log.Writer())
if err != nil {
util.TraceToLog()
return
}
} else if e.waitString != "" {
_, err = e.dockerSys.ContainerLogsWaitTextWithTimeout(e.containerID, e.waitString, e.waitStringTimeout, log.Writer())
if err != nil {
util.TraceToLog()
return
}
}
if e.network == nil {
e.IPV4Address, err = e.FindCurrentIPV4Address()
if err != nil {
util.TraceToLog()
return
}
}
e.chaos.serviceStartedAt = time.Now()
e.startedAfterBuild = true
if len(*e.onContainerReady) == 0 {
*e.onContainerReady <- true
}
return
}