Skip to content

Commit

Permalink
max virtual memory areas (docker-library/elasticsearch#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
ndegory committed Jan 2, 2017
1 parent 15ce96b commit fec89c5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
15 changes: 15 additions & 0 deletions cmd/amp/platform_infrastructure.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import (
"github.com/appcelerator/amp/config"
"github.com/docker/docker/api/types/mount"
"github.com/docker/docker/api/types/swarm"

"os"
"os/exec"
)

const (
Expand Down Expand Up @@ -675,3 +678,15 @@ func getAMPInfrastructureStack(m *ampManager) *ampStack {
//return stack
return &stack
}

func systemPrerequisites(m *ampManager) (err error) {
goos := os.Getenv("GOOS")
if goos == "linux" {
cmd := exec.Command("sysctl", "-w", "vm.max_map_count=262144")
if m.verbose {
m.printf(colRegular, "setting max virtual memory areas")
}
err = cmd.Run()
}
return nil
}
4 changes: 4 additions & 0 deletions cmd/amp/platform_start.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ func startAMP(cmd *cobra.Command, args []string) error {
manager.printf(colWarn, "Mode force: start anyway\n")
}
}
if err := systemPrerequisites(manager); err != nil {
manager.printf(colError, "Prerequisite error: %v\n", err)
os.Exit(1)
}
if err := manager.start(stack); err != nil {
manager.printf(colError, "Start error: %v\n", err)
if err := manager.stop(stack); err != nil {
Expand Down

0 comments on commit fec89c5

Please sign in to comment.