1
0
mirror of https://github.com/rancher/os.git synced 2025-09-09 02:31:36 +00:00

Move around code for better clarity

This commit is contained in:
Darren Shepherd
2018-09-15 21:55:26 -07:00
committed by niusmallnan
parent 2f50b7b178
commit 1f50386828
112 changed files with 992 additions and 859 deletions

53
pkg/init/docker/docker.go Normal file
View File

@@ -0,0 +1,53 @@
package docker
import (
"syscall"
"github.com/rancher/os/config"
"github.com/rancher/os/pkg/dfs"
)
func Start(cfg *config.CloudConfig) (chan interface{}, error) {
launchConfig, args := GetLaunchConfig(cfg, &cfg.Rancher.BootstrapDocker)
launchConfig.Fork = true
launchConfig.LogFile = ""
launchConfig.NoLog = true
cmd, err := dfs.LaunchDocker(launchConfig, config.SystemDockerBin, args...)
if err != nil {
return nil, err
}
c := make(chan interface{})
go func() {
<-c
cmd.Process.Signal(syscall.SIGTERM)
cmd.Wait()
c <- struct{}{}
}()
return c, nil
}
func Stop(c chan interface{}) error {
c <- struct{}{}
<-c
return nil
}
func GetLaunchConfig(cfg *config.CloudConfig, dockerCfg *config.DockerConfig) (*dfs.Config, []string) {
var launchConfig dfs.Config
args := dfs.ParseConfig(&launchConfig, dockerCfg.FullArgs()...)
launchConfig.DNSConfig.Nameservers = cfg.Rancher.Defaults.Network.DNS.Nameservers
launchConfig.DNSConfig.Search = cfg.Rancher.Defaults.Network.DNS.Search
launchConfig.Environment = dockerCfg.Environment
if !cfg.Rancher.Debug {
launchConfig.LogFile = config.SystemDockerLog
}
return &launchConfig, args
}