Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
af74b807
Commit
af74b807
authored
Jun 24, 2020
by
Heinrich Lee Yu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Merge branch 'revert-
915eb921
' into 'master'"
This reverts merge request !34291
parent
230adfd7
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
59 additions
and
48 deletions
+59
-48
config/application.rb
config/application.rb
+0
-16
config/environments/development.rb
config/environments/development.rb
+0
-2
config/environments/production.rb
config/environments/production.rb
+0
-2
config/gitlab.yml.example
config/gitlab.yml.example
+3
-0
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+1
-0
config/initializers/7_redis.rb
config/initializers/7_redis.rb
+11
-0
config/initializers/action_cable.rb
config/initializers/action_cable.rb
+3
-3
lib/gitlab/runtime.rb
lib/gitlab/runtime.rb
+14
-12
spec/lib/gitlab/runtime_spec.rb
spec/lib/gitlab/runtime_spec.rb
+27
-13
No files found.
config/application.rb
View file @
af74b807
...
...
@@ -17,16 +17,11 @@ module Gitlab
class
Application
<
Rails
::
Application
require_dependency
Rails
.
root
.
join
(
'lib/gitlab'
)
require_dependency
Rails
.
root
.
join
(
'lib/gitlab/utils'
)
require_dependency
Rails
.
root
.
join
(
'lib/gitlab/redis/wrapper'
)
require_dependency
Rails
.
root
.
join
(
'lib/gitlab/redis/cache'
)
require_dependency
Rails
.
root
.
join
(
'lib/gitlab/redis/queues'
)
require_dependency
Rails
.
root
.
join
(
'lib/gitlab/redis/shared_state'
)
require_dependency
Rails
.
root
.
join
(
'lib/gitlab/current_settings'
)
require_dependency
Rails
.
root
.
join
(
'lib/gitlab/middleware/read_only'
)
require_dependency
Rails
.
root
.
join
(
'lib/gitlab/middleware/basic_health_check'
)
require_dependency
Rails
.
root
.
join
(
'lib/gitlab/middleware/same_site_cookies'
)
require_dependency
Rails
.
root
.
join
(
'lib/gitlab/middleware/handle_ip_spoof_attack_error'
)
require_dependency
Rails
.
root
.
join
(
'lib/gitlab/runtime'
)
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
...
...
@@ -264,17 +259,6 @@ module Gitlab
end
end
# Use caching across all environments
# Full list of options:
# https://api.rubyonrails.org/classes/ActiveSupport/Cache/RedisCacheStore.html#method-c-new
caching_config_hash
=
{}
caching_config_hash
[
:redis
]
=
Gitlab
::
Redis
::
Cache
.
pool
caching_config_hash
[
:compress
]
=
Gitlab
::
Utils
.
to_boolean
(
ENV
.
fetch
(
'ENABLE_REDIS_CACHE_COMPRESSION'
,
'1'
))
caching_config_hash
[
:namespace
]
=
Gitlab
::
Redis
::
Cache
::
CACHE_NAMESPACE
caching_config_hash
[
:expires_in
]
=
2
.
weeks
# Cache should not grow forever
config
.
cache_store
=
:redis_cache_store
,
caching_config_hash
config
.
active_job
.
queue_adapter
=
:sidekiq
# This is needed for gitlab-shell
...
...
config/environments/development.rb
View file @
af74b807
...
...
@@ -49,8 +49,6 @@ Rails.application.configure do
# Do not log asset requests
config
.
assets
.
quiet
=
true
config
.
allow_concurrency
=
Gitlab
::
Runtime
.
multi_threaded?
# BetterErrors live shell (REPL) on every stack frame
BetterErrors
::
Middleware
.
allow_ip!
(
"127.0.0.1/0"
)
...
...
config/environments/production.rb
View file @
af74b807
...
...
@@ -77,6 +77,4 @@ Rails.application.configure do
config
.
action_mailer
.
raise_delivery_errors
=
true
config
.
eager_load
=
true
config
.
allow_concurrency
=
Gitlab
::
Runtime
.
multi_threaded?
end
config/gitlab.yml.example
View file @
af74b807
...
...
@@ -1113,6 +1113,9 @@ production: &base
## ActionCable settings
action_cable:
# Enables handling of ActionCable requests on the Puma web workers
# When this is disabled, a standalone ActionCable server must be started
in_app: true
# Number of threads used to process ActionCable connection callbacks and channel actions
# worker_pool_size: 4
...
...
config/initializers/1_settings.rb
View file @
af74b807
...
...
@@ -744,6 +744,7 @@ Settings.webpack.dev_server['port'] ||= 3808
# ActionCable settings
#
Settings
[
'action_cable'
]
||=
Settingslogic
.
new
({})
Settings
.
action_cable
[
'in_app'
]
||=
false
Settings
.
action_cable
[
'worker_pool_size'
]
||=
4
#
...
...
config/initializers/7_redis.rb
View file @
af74b807
# Use caching across all environments
# Full list of options:
# https://api.rubyonrails.org/classes/ActiveSupport/Cache/RedisCacheStore.html#method-c-new
caching_config_hash
=
{}
caching_config_hash
[
:redis
]
=
Gitlab
::
Redis
::
Cache
.
pool
caching_config_hash
[
:compress
]
=
Gitlab
::
Utils
.
to_boolean
(
ENV
.
fetch
(
'ENABLE_REDIS_CACHE_COMPRESSION'
,
'1'
))
caching_config_hash
[
:namespace
]
=
Gitlab
::
Redis
::
Cache
::
CACHE_NAMESPACE
caching_config_hash
[
:expires_in
]
=
2
.
weeks
# Cache should not grow forever
Gitlab
::
Application
.
config
.
cache_store
=
:redis_cache_store
,
caching_config_hash
# Make sure we initialize a Redis connection pool before multi-threaded
# execution starts by
# 1. Sidekiq
...
...
config/initializers/action_cable.rb
View file @
af74b807
...
...
@@ -3,9 +3,9 @@
require
'action_cable/subscription_adapter/redis'
Rails
.
application
.
configure
do
#
We only mount the ActionCable engine in tests where we run it in-app
# For other environments, we run it on a standalone Puma server
config
.
action_cable
.
mount_path
=
Rails
.
env
.
test?
?
'/-/cable'
:
nil
#
Mount the ActionCable engine when in-app mode is enabled
config
.
action_cable
.
mount_path
=
Gitlab
.
config
.
action_cable
.
in_app
?
'/-/cable'
:
nil
config
.
action_cable
.
url
=
Gitlab
::
Utils
.
append_path
(
Gitlab
.
config
.
gitlab
.
relative_url_root
,
'/-/cable'
)
config
.
action_cable
.
worker_pool_size
=
Gitlab
.
config
.
action_cable
.
worker_pool_size
end
...
...
lib/gitlab/runtime.rb
View file @
af74b807
...
...
@@ -37,7 +37,7 @@ module Gitlab
end
def
puma?
!!
defined?
(
::
Puma
)
&&
!
defined?
(
ACTION_CABLE_SERVER
)
!!
defined?
(
::
Puma
)
end
# For unicorn, we need to check for actual server instances to avoid false positives.
...
...
@@ -70,11 +70,11 @@ module Gitlab
end
def
web_server?
puma?
||
unicorn?
||
action_cable?
puma?
||
unicorn?
end
def
action_cable?
!!
defined?
(
ACTION_CABLE_SERVER
)
web_server?
&&
(
!!
defined?
(
ACTION_CABLE_SERVER
)
||
Gitlab
.
config
.
action_cable
.
in_app
)
end
def
multi_threaded?
...
...
@@ -82,19 +82,21 @@ module Gitlab
end
def
max_threads
main_thread
=
1
threads
=
1
# main thread
if
action_cable?
Gitlab
::
Application
.
config
.
action_cable
.
worker_pool_size
elsif
puma?
Puma
.
cli_config
.
options
[
:max_threads
]
if
puma?
threads
+=
Puma
.
cli_config
.
options
[
:max_threads
]
elsif
sidekiq?
# An extra thread for the poller in Sidekiq Cron:
# https://github.com/ondrejbartas/sidekiq-cron#under-the-hood
Sidekiq
.
options
[
:concurrency
]
+
1
else
0
end
+
main_thread
threads
+=
Sidekiq
.
options
[
:concurrency
]
+
1
end
if
action_cable?
threads
+=
Gitlab
.
config
.
action_cable
.
worker_pool_size
end
threads
end
end
end
...
...
spec/lib/gitlab/runtime_spec.rb
View file @
af74b807
...
...
@@ -48,18 +48,45 @@ RSpec.describe Gitlab::Runtime do
before
do
stub_const
(
'::Puma'
,
puma_type
)
allow
(
puma_type
).
to
receive_message_chain
(
:cli_config
,
:options
).
and_return
(
max_threads:
2
)
stub_config
(
action_cable:
{
in_app:
false
})
end
it_behaves_like
"valid runtime"
,
:puma
,
3
context
"when ActionCable in-app mode is enabled"
do
before
do
stub_config
(
action_cable:
{
in_app:
true
,
worker_pool_size:
3
})
end
it_behaves_like
"valid runtime"
,
:puma
,
6
end
context
"when ActionCable standalone is run"
do
before
do
stub_const
(
'ACTION_CABLE_SERVER'
,
true
)
stub_config
(
action_cable:
{
worker_pool_size:
8
})
end
it_behaves_like
"valid runtime"
,
:puma
,
11
end
end
context
"unicorn"
do
before
do
stub_const
(
'::Unicorn'
,
Module
.
new
)
stub_const
(
'::Unicorn::HttpServer'
,
Class
.
new
)
stub_config
(
action_cable:
{
in_app:
false
})
end
it_behaves_like
"valid runtime"
,
:unicorn
,
1
context
"when ActionCable in-app mode is enabled"
do
before
do
stub_config
(
action_cable:
{
in_app:
true
,
worker_pool_size:
3
})
end
it_behaves_like
"valid runtime"
,
:unicorn
,
4
end
end
context
"sidekiq"
do
...
...
@@ -105,17 +132,4 @@ RSpec.describe Gitlab::Runtime do
it_behaves_like
"valid runtime"
,
:rails_runner
,
1
end
context
"action_cable"
do
before
do
stub_const
(
'ACTION_CABLE_SERVER'
,
true
)
stub_const
(
'::Puma'
,
Module
.
new
)
allow
(
Gitlab
::
Application
).
to
receive_message_chain
(
:config
,
:action_cable
,
:worker_pool_size
).
and_return
(
8
)
end
it
"reports its maximum concurrency based on ActionCable's worker pool size"
do
expect
(
subject
.
max_threads
).
to
eq
(
9
)
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