Module: Gitlab::SetupHelper::Workhorse

Extended by:
Gitlab::SetupHelper
Defined in:
lib/gitlab/setup_helper.rb

Overview

rubocop:enable Rails/Output

Class Method Summary collapse

Methods included from Gitlab::SetupHelper

create_configuration, generate_configuration

Class Method Details

.compile_into(dir) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/gitlab/setup_helper.rb', line 52

def compile_into(dir)
  command = %W[#{make} -C #{Rails.root.join('workhorse')} install PREFIX=#{File.absolute_path(dir)}]

  make_out, make_status = Gitlab::Popen.popen(command)
  unless make_status == 0
    warn make_out
    raise 'workhorse make failed'
  end

  # 'make install' puts the binaries in #{dir}/bin but the init script expects them in dir
  FileUtils.mv(Dir["#{dir}/bin/*"], dir)
end

.configuration_toml(dir, _, _) ⇒ Object



34
35
36
37
38
# File 'lib/gitlab/setup_helper.rb', line 34

def configuration_toml(dir, _, _)
  config = { redis: { URL: redis_url, DB: redis_db } }

  TomlRB.dump(config)
end

.get_config_path(dir, _) ⇒ Object



48
49
50
# File 'lib/gitlab/setup_helper.rb', line 48

def get_config_path(dir, _)
  File.join(dir, 'config_path')
end

.makeObject



65
66
67
68
# File 'lib/gitlab/setup_helper.rb', line 65

def make
  _, which_status = Gitlab::Popen.popen(%w[which gmake])
  which_status == 0 ? 'gmake' : 'make'
end

.redis_dbObject



44
45
46
# File 'lib/gitlab/setup_helper.rb', line 44

def redis_db
  Gitlab::Redis::Workhorse.params.fetch(:db, 0)
end

.redis_urlObject



40
41
42
# File 'lib/gitlab/setup_helper.rb', line 40

def redis_url
  Gitlab::Redis::Workhorse.url
end