github.com/technosophos/deis@v1.7.1-0.20150915173815-f9005256004b/deisctl/cmd/platform.go (about)

     1  package cmd
     2  
     3  import (
     4  	"fmt"
     5  	"io"
     6  	"sync"
     7  
     8  	"github.com/deis/deis/deisctl/backend"
     9  	"github.com/deis/deis/deisctl/config"
    10  	"github.com/deis/deis/pkg/prettyprint"
    11  )
    12  
    13  // InstallPlatform loads all components' definitions from local unit files.
    14  // After InstallPlatform, all components will be available for StartPlatform.
    15  func InstallPlatform(b backend.Backend, cb config.Backend, checkKeys func(config.Backend) error, stateless bool) error {
    16  
    17  	if err := checkKeys(cb); err != nil {
    18  		return err
    19  	}
    20  
    21  	if stateless {
    22  		fmt.Println("Warning: With a stateless control plane, `deis logs` will be unavailable.")
    23  		fmt.Println("Additionally, components will need to be configured to use external persistent stores.")
    24  		fmt.Println("See the official Deis documentation for details on running a stateless control plane.")
    25  	}
    26  
    27  	var wg sync.WaitGroup
    28  
    29  	io.WriteString(Stdout, prettyprint.DeisIfy("Installing Deis..."))
    30  
    31  	installDefaultServices(b, stateless, &wg, Stdout, Stderr)
    32  
    33  	wg.Wait()
    34  
    35  	fmt.Fprintln(Stdout, "Done.")
    36  	fmt.Fprintln(Stdout, "")
    37  	if stateless {
    38  		fmt.Fprintln(Stdout, "Please run `deisctl start stateless-platform` to boot up Deis.")
    39  	} else {
    40  		fmt.Fprintln(Stdout, "Please run `deisctl start platform` to boot up Deis.")
    41  	}
    42  	return nil
    43  }
    44  
    45  // StartPlatform activates all components.
    46  func StartPlatform(b backend.Backend, stateless bool) error {
    47  
    48  	var wg sync.WaitGroup
    49  
    50  	io.WriteString(Stdout, prettyprint.DeisIfy("Starting Deis..."))
    51  
    52  	startDefaultServices(b, stateless, &wg, Stdout, Stderr)
    53  
    54  	wg.Wait()
    55  
    56  	fmt.Fprintln(Stdout, "Done.\n ")
    57  	fmt.Fprintln(Stdout, "Please set up an administrative account. See 'deis help register'")
    58  	return nil
    59  }
    60  
    61  // StopPlatform deactivates all components.
    62  func StopPlatform(b backend.Backend, stateless bool) error {
    63  
    64  	var wg sync.WaitGroup
    65  
    66  	io.WriteString(Stdout, prettyprint.DeisIfy("Stopping Deis..."))
    67  
    68  	stopDefaultServices(b, stateless, &wg, Stdout, Stderr)
    69  
    70  	wg.Wait()
    71  
    72  	fmt.Fprintln(Stdout, "Done.\n ")
    73  	if stateless {
    74  		fmt.Fprintln(Stdout, "Please run `deisctl start stateless-platform` to restart Deis.")
    75  	} else {
    76  		fmt.Fprintln(Stdout, "Please run `deisctl start platform` to restart Deis.")
    77  	}
    78  	return nil
    79  }
    80  
    81  // UninstallPlatform unloads all components' definitions.
    82  // After UninstallPlatform, all components will be unavailable.
    83  func UninstallPlatform(b backend.Backend, stateless bool) error {
    84  
    85  	var wg sync.WaitGroup
    86  
    87  	io.WriteString(Stdout, prettyprint.DeisIfy("Uninstalling Deis..."))
    88  
    89  	uninstallAllServices(b, stateless, &wg, Stdout, Stderr)
    90  
    91  	wg.Wait()
    92  
    93  	fmt.Fprintln(Stdout, "Done.")
    94  	return nil
    95  }