BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
765b1831
Commit
765b1831
authored
Aug 16, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'rs-redis-config-paths' into 'master'
Don't depend on `Rails` for Redis configuration file paths Closes #36514 See merge request !13575
parents
e254014d
f5cb3ac1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
16 deletions
+19
-16
cache.rb
lib/gitlab/redis/cache.rb
+1
-4
queues.rb
lib/gitlab/redis/queues.rb
+1
-4
shared_state.rb
lib/gitlab/redis/shared_state.rb
+1
-4
wrapper.rb
lib/gitlab/redis/wrapper.rb
+9
-4
wrapper_spec.rb
spec/lib/gitlab/redis/wrapper_spec.rb
+7
-0
No files found.
lib/gitlab/redis/cache.rb
View file @
765b1831
...
...
@@ -7,9 +7,6 @@ module Gitlab
CACHE_NAMESPACE
=
'cache:gitlab'
.
freeze
DEFAULT_REDIS_CACHE_URL
=
'redis://localhost:6380'
.
freeze
REDIS_CACHE_CONFIG_ENV_VAR_NAME
=
'GITLAB_REDIS_CACHE_CONFIG_FILE'
.
freeze
if
defined?
(
::
Rails
)
&&
::
Rails
.
root
.
present?
DEFAULT_REDIS_CACHE_CONFIG_FILE_NAME
=
::
Rails
.
root
.
join
(
'config'
,
'redis.cache.yml'
).
freeze
end
class
<<
self
def
default_url
...
...
@@ -22,7 +19,7 @@ module Gitlab
return
file_name
unless
file_name
.
nil?
# otherwise, if config files exists for this class, use it
file_name
=
File
.
expand_path
(
DEFAULT_REDIS_CACHE_CONFIG_FILE_NAME
,
__dir__
)
file_name
=
config_file_path
(
'redis.cache.yml'
)
return
file_name
if
File
.
file?
(
file_name
)
# this will force use of DEFAULT_REDIS_QUEUES_URL when config file is absent
...
...
lib/gitlab/redis/queues.rb
View file @
765b1831
...
...
@@ -8,9 +8,6 @@ module Gitlab
MAILROOM_NAMESPACE
=
'mail_room:gitlab'
.
freeze
DEFAULT_REDIS_QUEUES_URL
=
'redis://localhost:6381'
.
freeze
REDIS_QUEUES_CONFIG_ENV_VAR_NAME
=
'GITLAB_REDIS_QUEUES_CONFIG_FILE'
.
freeze
if
defined?
(
::
Rails
)
&&
::
Rails
.
root
.
present?
DEFAULT_REDIS_QUEUES_CONFIG_FILE_NAME
=
::
Rails
.
root
.
join
(
'config'
,
'redis.queues.yml'
).
freeze
end
class
<<
self
def
default_url
...
...
@@ -23,7 +20,7 @@ module Gitlab
return
file_name
if
file_name
# otherwise, if config files exists for this class, use it
file_name
=
File
.
expand_path
(
DEFAULT_REDIS_QUEUES_CONFIG_FILE_NAME
,
__dir__
)
file_name
=
config_file_path
(
'redis.queues.yml'
)
return
file_name
if
File
.
file?
(
file_name
)
# this will force use of DEFAULT_REDIS_QUEUES_URL when config file is absent
...
...
lib/gitlab/redis/shared_state.rb
View file @
765b1831
...
...
@@ -7,9 +7,6 @@ module Gitlab
SESSION_NAMESPACE
=
'session:gitlab'
.
freeze
DEFAULT_REDIS_SHARED_STATE_URL
=
'redis://localhost:6382'
.
freeze
REDIS_SHARED_STATE_CONFIG_ENV_VAR_NAME
=
'GITLAB_REDIS_SHARED_STATE_CONFIG_FILE'
.
freeze
if
defined?
(
::
Rails
)
&&
::
Rails
.
root
.
present?
DEFAULT_REDIS_SHARED_STATE_CONFIG_FILE_NAME
=
::
Rails
.
root
.
join
(
'config'
,
'redis.shared_state.yml'
).
freeze
end
class
<<
self
def
default_url
...
...
@@ -22,7 +19,7 @@ module Gitlab
return
file_name
if
file_name
# otherwise, if config files exists for this class, use it
file_name
=
File
.
expand_path
(
DEFAULT_REDIS_SHARED_STATE_CONFIG_FILE_NAME
,
__dir__
)
file_name
=
config_file_path
(
'redis.shared_state.yml'
)
return
file_name
if
File
.
file?
(
file_name
)
# this will force use of DEFAULT_REDIS_SHARED_STATE_URL when config file is absent
...
...
lib/gitlab/redis/wrapper.rb
View file @
765b1831
...
...
@@ -8,9 +8,6 @@ module Gitlab
class
Wrapper
DEFAULT_REDIS_URL
=
'redis://localhost:6379'
.
freeze
REDIS_CONFIG_ENV_VAR_NAME
=
'GITLAB_REDIS_CONFIG_FILE'
.
freeze
if
defined?
(
::
Rails
)
&&
::
Rails
.
root
.
present?
DEFAULT_REDIS_CONFIG_FILE_NAME
=
::
Rails
.
root
.
join
(
'config'
,
'resque.yml'
).
freeze
end
class
<<
self
delegate
:params
,
:url
,
to: :new
...
...
@@ -49,13 +46,21 @@ module Gitlab
DEFAULT_REDIS_URL
end
# Return the absolute path to a Rails configuration file
#
# We use this instead of `Rails.root` because for certain tasks
# utilizing these classes, `Rails` might not be available.
def
config_file_path
(
filename
)
File
.
expand_path
(
"../../../config/
#{
filename
}
"
,
__dir__
)
end
def
config_file_name
# if ENV set for wrapper class, use it even if it points to a file does not exist
file_name
=
ENV
[
REDIS_CONFIG_ENV_VAR_NAME
]
return
file_name
unless
file_name
.
nil?
# otherwise, if config files exists for wrapper class, use it
file_name
=
File
.
expand_path
(
DEFAULT_REDIS_CONFIG_FILE_NAME
,
__dir__
)
file_name
=
config_file_path
(
'resque.yml'
)
return
file_name
if
File
.
file?
(
file_name
)
# nil will force use of DEFAULT_REDIS_URL when config file is absent
...
...
spec/lib/gitlab/redis/wrapper_spec.rb
View file @
765b1831
...
...
@@ -17,4 +17,11 @@ describe Gitlab::Redis::Wrapper do
let
(
:class_redis_url
)
{
Gitlab
::
Redis
::
Wrapper
::
DEFAULT_REDIS_URL
}
include_examples
"redis_shared_examples"
describe
'.config_file_path'
do
it
'returns the absolute path to the configuration file'
do
expect
(
described_class
.
config_file_path
(
'foo.yml'
))
.
to
eq
Rails
.
root
.
join
(
'config'
,
'foo.yml'
).
to_s
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment