diff options
Diffstat (limited to 'config')
-rw-r--r-- | config/gitlab.yml.example | 16 | ||||
-rw-r--r-- | config/initializers/1_settings.rb | 31 | ||||
-rw-r--r-- | config/initializers/8_gitaly.rb | 20 |
3 files changed, 46 insertions, 21 deletions
diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example index 3747baf4c3b..d89e25c0959 100644 --- a/config/gitlab.yml.example +++ b/config/gitlab.yml.example @@ -443,14 +443,10 @@ production: &base # Gitaly settings gitaly: - # The socket_path setting is optional and obsolete. When this is set - # GitLab assumes it can reach a Gitaly services via a Unix socket at - # this path. When this is commented out GitLab will not use Gitaly. - # - # This setting is obsolete because we expect it to be moved under - # repositories/storages in GitLab 9.1. - # - # socket_path: tmp/sockets/private/gitaly.socket + # This setting controls whether GitLab uses Gitaly (new component + # introduced in 9.0). Eventually Gitaly use will become mandatory and + # this option will disappear. + enabled: false # # 4. Advanced settings @@ -465,6 +461,7 @@ production: &base storages: # You must have at least a `default` storage path. default: path: /home/git/repositories/ + gitaly_address: unix:/home/git/gitlab/tmp/sockets/private/gitaly.socket ## Backup settings backup: @@ -577,6 +574,9 @@ test: storages: default: path: tmp/tests/repositories/ + gitaly_address: unix:<%= Rails.root.join('tmp/sockets/private/gitaly.socket') %> + gitaly: + enabled: false backup: path: tmp/tests/backups gitlab_shell: diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index 62020fa9a75..e8fef0000c1 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -79,6 +79,10 @@ class Settings < Settingslogic value end + def absolute(path) + File.expand_path(path, Rails.root) + end + private def base_url(config) @@ -178,7 +182,7 @@ if github_settings end Settings['shared'] ||= Settingslogic.new({}) -Settings.shared['path'] = File.expand_path(Settings.shared['path'] || "shared", Rails.root) +Settings.shared['path'] = Settings.absolute(Settings.shared['path'] || "shared") Settings['issues_tracker'] ||= {} @@ -237,7 +241,7 @@ Settings['gitlab_ci'] ||= Settingslogic.new({}) Settings.gitlab_ci['shared_runners_enabled'] = true if Settings.gitlab_ci['shared_runners_enabled'].nil? Settings.gitlab_ci['all_broken_builds'] = true if Settings.gitlab_ci['all_broken_builds'].nil? Settings.gitlab_ci['add_pusher'] = false if Settings.gitlab_ci['add_pusher'].nil? -Settings.gitlab_ci['builds_path'] = File.expand_path(Settings.gitlab_ci['builds_path'] || "builds/", Rails.root) +Settings.gitlab_ci['builds_path'] = Settings.absolute(Settings.gitlab_ci['builds_path'] || "builds/") Settings.gitlab_ci['url'] ||= Settings.send(:build_gitlab_ci_url) # @@ -251,7 +255,7 @@ Settings.incoming_email['enabled'] = false if Settings.incoming_email['enabled'] # Settings['artifacts'] ||= Settingslogic.new({}) Settings.artifacts['enabled'] = true if Settings.artifacts['enabled'].nil? -Settings.artifacts['path'] = File.expand_path(Settings.artifacts['path'] || File.join(Settings.shared['path'], "artifacts"), Rails.root) +Settings.artifacts['path'] = Settings.absolute(Settings.artifacts['path'] || File.join(Settings.shared['path'], "artifacts")) Settings.artifacts['max_size'] ||= 100 # in megabytes # @@ -265,14 +269,14 @@ Settings.registry['api_url'] ||= "http://localhost:5000/" Settings.registry['key'] ||= nil Settings.registry['issuer'] ||= nil Settings.registry['host_port'] ||= [Settings.registry['host'], Settings.registry['port']].compact.join(':') -Settings.registry['path'] = File.expand_path(Settings.registry['path'] || File.join(Settings.shared['path'], 'registry'), Rails.root) +Settings.registry['path'] = Settings.absolute(Settings.registry['path'] || File.join(Settings.shared['path'], 'registry')) # # Pages # Settings['pages'] ||= Settingslogic.new({}) Settings.pages['enabled'] = false if Settings.pages['enabled'].nil? -Settings.pages['path'] = File.expand_path(Settings.pages['path'] || File.join(Settings.shared['path'], "pages"), Rails.root) +Settings.pages['path'] = Settings.absolute(Settings.pages['path'] || File.join(Settings.shared['path'], "pages")) Settings.pages['https'] = false if Settings.pages['https'].nil? Settings.pages['host'] ||= "example.com" Settings.pages['port'] ||= Settings.pages.https ? 443 : 80 @@ -286,7 +290,7 @@ Settings.pages['external_https'] ||= false unless Settings.pages['external_http # Settings['lfs'] ||= Settingslogic.new({}) Settings.lfs['enabled'] = true if Settings.lfs['enabled'].nil? -Settings.lfs['storage_path'] = File.expand_path(Settings.lfs['storage_path'] || File.join(Settings.shared['path'], "lfs-objects"), Rails.root) +Settings.lfs['storage_path'] = Settings.absolute(Settings.lfs['storage_path'] || File.join(Settings.shared['path'], "lfs-objects")) # # Mattermost @@ -350,8 +354,8 @@ Settings.cron_jobs['remove_unreferenced_lfs_objects_worker']['job_class'] = 'Rem # GitLab Shell # Settings['gitlab_shell'] ||= Settingslogic.new({}) -Settings.gitlab_shell['path'] ||= Settings.gitlab['user_home'] + '/gitlab-shell/' -Settings.gitlab_shell['hooks_path'] ||= Settings.gitlab['user_home'] + '/gitlab-shell/hooks/' +Settings.gitlab_shell['path'] = Settings.absolute(Settings.gitlab_shell['path'] || Settings.gitlab['user_home'] + '/gitlab-shell/') +Settings.gitlab_shell['hooks_path'] = Settings.absolute(Settings.gitlab_shell['hooks_path'] || Settings.gitlab['user_home'] + '/gitlab-shell/hooks/') Settings.gitlab_shell['secret_file'] ||= Rails.root.join('.gitlab_shell_secret') Settings.gitlab_shell['receive_pack'] = true if Settings.gitlab_shell['receive_pack'].nil? Settings.gitlab_shell['upload_pack'] = true if Settings.gitlab_shell['upload_pack'].nil? @@ -374,6 +378,11 @@ unless Settings.repositories.storages['default'] Settings.repositories.storages['default']['path'] ||= Settings.gitlab['user_home'] + '/repositories/' end +Settings.repositories.storages.values.each do |storage| + # Expand relative paths + storage['path'] = Settings.absolute(storage['path']) +end + # # The repository_downloads_path is used to remove outdated repository # archives, if someone has it configured incorrectly, and it points @@ -395,7 +404,7 @@ end Settings['backup'] ||= Settingslogic.new({}) Settings.backup['keep_time'] ||= 0 Settings.backup['pg_schema'] = nil -Settings.backup['path'] = File.expand_path(Settings.backup['path'] || "tmp/backups/", Rails.root) +Settings.backup['path'] = Settings.absolute(Settings.backup['path'] || "tmp/backups/") Settings.backup['archive_permissions'] ||= 0600 Settings.backup['upload'] ||= Settingslogic.new({ 'remote_directory' => nil, 'connection' => nil }) # Convert upload connection settings to use symbol keys, to make Fog happy @@ -418,7 +427,7 @@ Settings.git['timeout'] ||= 10 # least. This setting is fed to 'rm -rf' in # db/migrate/20151023144219_remove_satellites.rb Settings['satellites'] ||= Settingslogic.new({}) -Settings.satellites['path'] = File.expand_path(Settings.satellites['path'] || "tmp/repo_satellites/", Rails.root) +Settings.satellites['path'] = Settings.absolute(Settings.satellites['path'] || "tmp/repo_satellites/") # # Extra customization @@ -440,7 +449,7 @@ Settings.rack_attack.git_basic_auth['bantime'] ||= 1.hour # Gitaly # Settings['gitaly'] ||= Settingslogic.new({}) -Settings.gitaly['socket_path'] ||= ENV['GITALY_SOCKET_PATH'] +Settings.gitaly['enabled'] ||= false # # Webpack settings diff --git a/config/initializers/8_gitaly.rb b/config/initializers/8_gitaly.rb index 07dd30f0a24..69c0a91d6f0 100644 --- a/config/initializers/8_gitaly.rb +++ b/config/initializers/8_gitaly.rb @@ -1,2 +1,18 @@ -# Make sure we initialize a Gitaly channel before Sidekiq starts multi-threaded execution. -Gitlab::GitalyClient.channel unless Rails.env.test? +require 'uri' + +# Make sure we initialize our Gitaly channels before Sidekiq starts multi-threaded execution. +if Gitlab.config.gitaly.enabled || Rails.env.test? + Gitlab.config.repositories.storages.each do |name, params| + address = params['gitaly_address'] + + unless address.present? + raise "storage #{name.inspect} is missing a gitaly_address" + end + + unless URI(address).scheme == 'unix' + raise "Unsupported Gitaly address: #{address.inspect}" + end + + Gitlab::GitalyClient.configure_channel(name, address) + end +end |