Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AMP Bootstrap #528

Merged
merged 2 commits into from
Dec 8, 2016
Merged

AMP Bootstrap #528

merged 2 commits into from
Dec 8, 2016

Conversation

ndegory
Copy link
Contributor

@ndegory ndegory commented Dec 7, 2016

resolves #306

subcommand of amp cluster cli to bootstrap a node (Docker, Swarm, cluster agent and server services)

$ amp-cluster bootstrap -h
Installs Docker, setups Swarm, run the AMP agent

Usage:
  amp-cluster bootstrap [flags]

Aliases:
  bootstrap, bs


Flags:
  -c, --create         initializes the Swarm (needs option -m)
      --host string    Swarm manager hostname
  -m, --manager        bootstraps a Swarm manager node
      --port string    Swarm manager port (default "2377")
      --tag string     AMP image version (default "v0.4.0-dev")
      --token string   Swarm join token

Global Flags:
      --config string   Config file (default is $HOME/.amp.yaml)
      --debug           display debug information
      --server string   define the remote server address (default "127.0.0.1:31315")
      --silence         No output
  -v, --verbose         Verbose output

@freignat91 freignat91 self-assigned this Dec 7, 2016
@ndegory
Copy link
Contributor Author

ndegory commented Dec 7, 2016

tested: manager initialization (sudo amp-cluster bootstrap -m -c --tag cluster) on Ubuntu 16.04 and CentOS 7.

var SwarmJoinToken string
var AmpImageTag string
var CreateSwarm bool
var Manager bool
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These vars should have their first letter lowercase concidering they are only local

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, done

log.Println("Docker engine version is just fine")
}
if err := c.enableDockerEngine(); err != nil {
log.Fatalf("Failed to enable the Docker service: %s\n", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use g.fatalc("%v\n", err) in place of log.Fatalln to have color output
globally use g.printfc(...) in place of log to have color output the same way then in the orther commands
including in bootstrap-docker.go file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, done (but now I have to background color issue...)

versionCmd := [...]string{"docker", "version", "-f", "{{ .Server.Version }}"}
cmd := exec.Command(versionCmd[0], versionCmd[1:]...)
cmd.Stdout = &out
cmd.Stderr = &stderr
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you want to see output you can also use:
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't, I don't want to output it on the console, I use the output later


func (c *clusterClient) pullAmpImage(version string) error {
image := "appcelerator/amp:" + version
_, err := c.dockerClient.ImagePull(c.ctx, image, types.ImagePullOptions{})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't use the reader, so you don't know if pull has error or not during pull

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, done

Copy link
Contributor

@freignat91 freignat91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@freignat91 freignat91 merged commit 1d0f21d into infra-swarm-client-server Dec 8, 2016
@freignat91 freignat91 deleted the bootstrap branch December 8, 2016 15:03
freignat91 pushed a commit that referenced this pull request Dec 8, 2016
* add bootstrap feature to AMP cluster CLI (#306)

* update vendors (huge diff)
ndegory added a commit that referenced this pull request Dec 8, 2016
* add bootstrap feature to AMP cluster CLI (#306)

* update vendors (huge diff)
@ndegory ndegory added this to the 0.4.0 milestone Dec 12, 2016
@ndegory ndegory modified the milestones: 0.5.0, 0.4.0 Dec 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants