1
0
mirror of https://github.com/rancher/os.git synced 2025-07-15 15:51:36 +00:00

Add option to disable startup of services

This commit is contained in:
Darren Shepherd 2015-04-04 10:03:31 -07:00
parent a1f912c4d5
commit 36f5b16194
2 changed files with 27 additions and 12 deletions

View File

@ -47,17 +47,17 @@ type Config struct {
CloudInit CloudInit `yaml:"cloud_init,omitempty"`
Console ConsoleConfig `yaml:"console,omitempty"`
Debug bool `yaml:"debug,omitempty"`
//Disable []string `yaml:"disable,omitempty"`
EnabledAddons []string `yaml:"enabled_addons,omitempty"`
Modules []string `yaml:"modules,omitempty"`
Network NetworkConfig `yaml:"network,omitempty"`
Ssh SshConfig `yaml:"ssh,omitempty"`
State StateConfig `yaml:"state,omitempty"`
SystemContainers map[string]*project.ServiceConfig `yaml:"system_containers,omitempty"`
SystemDocker DockerConfig `yaml:"system_docker,omitempty"`
Upgrade UpgradeConfig `yaml:"upgrade,omitempty"`
UserContainers []ContainerConfig `yaml:"user_containers,omitempty"`
UserDocker DockerConfig `yaml:"user_docker,omitempty"`
Disable []string `yaml:"disable,omitempty"`
EnabledAddons []string `yaml:"enabled_addons,omitempty"`
Modules []string `yaml:"modules,omitempty"`
Network NetworkConfig `yaml:"network,omitempty"`
Ssh SshConfig `yaml:"ssh,omitempty"`
State StateConfig `yaml:"state,omitempty"`
SystemContainers map[string]*project.ServiceConfig `yaml:"system_containers,omitempty"`
SystemDocker DockerConfig `yaml:"system_docker,omitempty"`
Upgrade UpgradeConfig `yaml:"upgrade,omitempty"`
UserContainers []ContainerConfig `yaml:"user_containers,omitempty"`
UserDocker DockerConfig `yaml:"user_docker,omitempty"`
}
type ConsoleConfig struct {

View File

@ -4,10 +4,12 @@ import (
log "github.com/Sirupsen/logrus"
"github.com/rancherio/os/config"
"github.com/rancherio/os/util"
"github.com/rancherio/rancher-compose/project"
)
type ContainerFactory struct {
cfg *config.Config
}
type containerBasedService struct {
@ -18,11 +20,23 @@ type containerBasedService struct {
cfg *config.Config
}
func NewContainerFactory(cfg *config.Config) *ContainerFactory {
return &ContainerFactory{
cfg: cfg,
}
}
func (c *containerBasedService) Up() error {
container := c.container
containerCfg := c.container.ContainerCfg
if containerCfg.CreateOnly {
create := containerCfg.CreateOnly
if util.Contains(c.cfg.Disable, c.name) {
create = true
}
if create {
container.Create()
c.project.Notify(project.CONTAINER_CREATED, c, map[string]string{
project.CONTAINER_ID: container.Container.ID,
@ -65,5 +79,6 @@ func (c *ContainerFactory) Create(project *project.Project, name string, service
project: project,
container: container,
serviceConfig: serviceConfig,
cfg: c.cfg,
}, nil
}