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

First class consoles

This commit is contained in:
Josh Curl
2016-06-06 15:13:15 -07:00
parent b83f0ec092
commit 719d255636
16 changed files with 302 additions and 103 deletions

View File

@@ -0,0 +1,41 @@
package switchconsole
import (
"os"
log "github.com/Sirupsen/logrus"
"github.com/docker/libcompose/project/options"
"github.com/rancher/os/compose"
"github.com/rancher/os/config"
"golang.org/x/net/context"
)
func Main() {
if len(os.Args) != 2 {
log.Fatal("Must specify exactly one existing container")
}
newConsole := os.Args[1]
cfg := config.LoadConfig()
project, err := compose.GetProject(cfg, true)
if err != nil {
log.Fatal(err)
}
if err = compose.LoadService(project, cfg, true, newConsole); err != nil {
log.Fatal(err)
}
if err = project.Up(context.Background(), options.Up{}, "console"); err != nil {
log.Fatal(err)
}
if err = project.Restart(context.Background(), 10, "docker"); err != nil {
log.Errorf("Failed to restart Docker: %v", err)
}
if err = config.Set("rancher.console", newConsole); err != nil {
log.Errorf("Failed to update 'rancher.console': %v", err)
}
}