diff options
author | Jacob Vosmaer <jacob@gitlab.com> | 2017-03-13 17:04:46 +0300 |
---|---|---|
committer | Jacob Vosmaer <jacob@gitlab.com> | 2017-03-21 16:55:41 +0300 |
commit | 3883a5f906742dd6cf6cccec47b495c661ec7b01 (patch) | |
tree | a68be0007e4152ce27d472bec105fde46e233e75 /lib | |
parent | 0ebf14621fe02adbf874bcb694a7be78794ec89c (diff) |
Rake task that can install gitaly at a tag version
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/gitaly_client.rb | 7 | ||||
-rw-r--r-- | lib/tasks/gitlab/gitaly.rake | 23 |
2 files changed, 30 insertions, 0 deletions
diff --git a/lib/gitlab/gitaly_client.rb b/lib/gitlab/gitaly_client.rb index 5534d4af439..1ce47ef2b05 100644 --- a/lib/gitlab/gitaly_client.rb +++ b/lib/gitlab/gitaly_client.rb @@ -2,6 +2,8 @@ require 'gitaly' module Gitlab module GitalyClient + SERVER_VERSION_FILE = 'GITALY_SERVER_VERSION'.freeze + def self.gitaly_address if Gitlab.config.gitaly.socket_path "unix://#{Gitlab.config.gitaly.socket_path}" @@ -39,5 +41,10 @@ module Gitlab yield is_enabled end end + + def self.expected_server_version + path = Rails.root.join(SERVER_VERSION_FILE) + path.read.chomp + end end end diff --git a/lib/tasks/gitlab/gitaly.rake b/lib/tasks/gitlab/gitaly.rake new file mode 100644 index 00000000000..c288e17ac8d --- /dev/null +++ b/lib/tasks/gitlab/gitaly.rake @@ -0,0 +1,23 @@ +namespace :gitlab do + namespace :gitaly do + desc "GitLab | Install or upgrade gitaly" + task :install, [:dir] => :environment do |t, args| + warn_user_is_not_gitlab + unless args.dir.present? + abort %(Please specify the directory where you want to install gitaly:\n rake "gitlab:gitaly:install[/home/git/gitaly]") + end + + tag = "v#{Gitlab::GitalyClient.expected_server_version}" + repo = 'https://gitlab.com/gitlab-org/gitaly.git' + + checkout_or_clone_tag(tag: tag, repo: repo, target_dir: args.dir) + + _, status = Gitlab::Popen.popen(%w[which gmake]) + command = status.zero? ? 'gmake' : 'make' + + Dir.chdir(args.dir) do + run_command!([command]) + end + end + end +end |