1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
16 "git.arvados.org/arvados.git/sdk/go/arvados"
19 // Don't trust "passenger-config" (or "bundle install") to handle
20 // concurrent installs.
21 var passengerInstallMutex sync.Mutex
23 // Install a Rails application's dependencies, including phusion
25 type installPassenger struct {
27 depends []supervisedTask
30 func (runner installPassenger) String() string {
31 return "installPassenger:" + runner.src
34 func (runner installPassenger) Run(ctx context.Context, fail func(error), super *Supervisor) error {
35 err := super.wait(ctx, runner.depends...)
40 passengerInstallMutex.Lock()
41 defer passengerInstallMutex.Unlock()
44 err = super.RunProgram(ctx, runner.src, &buf, nil, "gem", "list", "--details", "bundler")
48 for _, version := range []string{"1.11.0", "1.17.3", "2.0.2"} {
49 if !strings.Contains(buf.String(), "("+version+")") {
50 err = super.RunProgram(ctx, runner.src, nil, nil, "gem", "install", "--user", "bundler:1.11", "bundler:1.17.3", "bundler:2.0.2")
57 err = super.RunProgram(ctx, runner.src, nil, nil, "bundle", "install", "--jobs", "4", "--path", filepath.Join(os.Getenv("HOME"), ".gem"))
61 err = super.RunProgram(ctx, runner.src, nil, nil, "bundle", "exec", "passenger-config", "build-native-support")
65 err = super.RunProgram(ctx, runner.src, nil, nil, "bundle", "exec", "passenger-config", "install-standalone-runtime")
69 err = super.RunProgram(ctx, runner.src, nil, nil, "bundle", "exec", "passenger-config", "validate-install")
76 type runPassenger struct {
79 depends []supervisedTask
82 func (runner runPassenger) String() string {
83 return "runPassenger:" + runner.src
86 func (runner runPassenger) Run(ctx context.Context, fail func(error), super *Supervisor) error {
87 err := super.wait(ctx, runner.depends...)
91 port, err := internalPort(runner.svc)
93 return fmt.Errorf("bug: no internalPort for %q: %v (%#v)", runner, err, runner.svc)
96 if lvl, ok := map[string]string{
104 }[super.cluster.SystemLogs.LogLevel]; ok {
107 super.waitShutdown.Add(1)
109 defer super.waitShutdown.Done()
110 err = super.RunProgram(ctx, runner.src, nil, nil, "bundle", "exec",
111 "passenger", "start",
113 "--log-file", "/dev/stderr",
114 "--log-level", loglevel,
115 "--no-friendly-error-pages",
116 "--pid-file", filepath.Join(super.tempdir, "passenger."+strings.Replace(runner.src, "/", "_", -1)+".pid"))