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
57cdb4c5
Commit
57cdb4c5
authored
Jun 10, 2020
by
Heinrich Lee Yu
Committed by
Mayra Cabrera
Jun 10, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Merge branch '214061-actioncable-embedded-mode' into 'master'"
This reverts merge request !33943
parent
07b6587b
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
48 additions
and
59 deletions
+48
-59
config/application.rb
config/application.rb
+16
-0
config/environments/development.rb
config/environments/development.rb
+2
-0
config/environments/production.rb
config/environments/production.rb
+2
-0
config/gitlab.yml.example
config/gitlab.yml.example
+0
-3
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+0
-1
config/initializers/7_redis.rb
config/initializers/7_redis.rb
+0
-11
config/initializers/action_cable.rb
config/initializers/action_cable.rb
+3
-3
lib/gitlab/runtime.rb
lib/gitlab/runtime.rb
+12
-14
spec/lib/gitlab/runtime_spec.rb
spec/lib/gitlab/runtime_spec.rb
+13
-27
No files found.
config/application.rb
View file @
57cdb4c5
...
@@ -17,11 +17,16 @@ module Gitlab
...
@@ -17,11 +17,16 @@ module Gitlab
class
Application
<
Rails
::
Application
class
Application
<
Rails
::
Application
require_dependency
Rails
.
root
.
join
(
'lib/gitlab'
)
require_dependency
Rails
.
root
.
join
(
'lib/gitlab'
)
require_dependency
Rails
.
root
.
join
(
'lib/gitlab/utils'
)
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/current_settings'
)
require_dependency
Rails
.
root
.
join
(
'lib/gitlab/middleware/read_only'
)
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/basic_health_check'
)
require_dependency
Rails
.
root
.
join
(
'lib/gitlab/middleware/same_site_cookies'
)
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/middleware/handle_ip_spoof_attack_error'
)
require_dependency
Rails
.
root
.
join
(
'lib/gitlab/runtime'
)
# Settings in config/environments/* take precedence over those specified here.
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# Application configuration should go into files in config/initializers
...
@@ -257,6 +262,17 @@ module Gitlab
...
@@ -257,6 +262,17 @@ module Gitlab
end
end
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
config
.
active_job
.
queue_adapter
=
:sidekiq
# This is needed for gitlab-shell
# This is needed for gitlab-shell
...
...
config/environments/development.rb
View file @
57cdb4c5
...
@@ -49,6 +49,8 @@ Rails.application.configure do
...
@@ -49,6 +49,8 @@ Rails.application.configure do
# Do not log asset requests
# Do not log asset requests
config
.
assets
.
quiet
=
true
config
.
assets
.
quiet
=
true
config
.
allow_concurrency
=
Gitlab
::
Runtime
.
multi_threaded?
# BetterErrors live shell (REPL) on every stack frame
# BetterErrors live shell (REPL) on every stack frame
BetterErrors
::
Middleware
.
allow_ip!
(
"127.0.0.1/0"
)
BetterErrors
::
Middleware
.
allow_ip!
(
"127.0.0.1/0"
)
...
...
config/environments/production.rb
View file @
57cdb4c5
...
@@ -77,4 +77,6 @@ Rails.application.configure do
...
@@ -77,4 +77,6 @@ Rails.application.configure do
config
.
action_mailer
.
raise_delivery_errors
=
true
config
.
action_mailer
.
raise_delivery_errors
=
true
config
.
eager_load
=
true
config
.
eager_load
=
true
config
.
allow_concurrency
=
Gitlab
::
Runtime
.
multi_threaded?
end
end
config/gitlab.yml.example
View file @
57cdb4c5
...
@@ -1075,9 +1075,6 @@ production: &base
...
@@ -1075,9 +1075,6 @@ production: &base
## ActionCable settings
## ActionCable settings
action_cable:
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
# Number of threads used to process ActionCable connection callbacks and channel actions
# worker_pool_size: 4
# worker_pool_size: 4
...
...
config/initializers/1_settings.rb
View file @
57cdb4c5
...
@@ -729,7 +729,6 @@ Settings.webpack.dev_server['port'] ||= 3808
...
@@ -729,7 +729,6 @@ Settings.webpack.dev_server['port'] ||= 3808
# ActionCable settings
# ActionCable settings
#
#
Settings
[
'action_cable'
]
||=
Settingslogic
.
new
({})
Settings
[
'action_cable'
]
||=
Settingslogic
.
new
({})
Settings
.
action_cable
[
'in_app'
]
||=
false
Settings
.
action_cable
[
'worker_pool_size'
]
||=
4
Settings
.
action_cable
[
'worker_pool_size'
]
||=
4
#
#
...
...
config/initializers/7_redis.rb
View file @
57cdb4c5
# 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
# Make sure we initialize a Redis connection pool before multi-threaded
# execution starts by
# execution starts by
# 1. Sidekiq
# 1. Sidekiq
...
...
config/initializers/action_cable.rb
View file @
57cdb4c5
...
@@ -3,9 +3,9 @@
...
@@ -3,9 +3,9 @@
require
'action_cable/subscription_adapter/redis'
require
'action_cable/subscription_adapter/redis'
Rails
.
application
.
configure
do
Rails
.
application
.
configure
do
#
Mount the ActionCable engine when in-app mode is enabled
#
We only mount the ActionCable engine in tests where we run it in-app
config
.
action_cable
.
mount_path
=
Gitlab
.
config
.
action_cable
.
in_app
?
'/-/cable'
:
nil
# For other environments, we run it on a standalone Puma server
config
.
action_cable
.
mount_path
=
Rails
.
env
.
test?
?
'/-/cable'
:
nil
config
.
action_cable
.
url
=
Gitlab
::
Utils
.
append_path
(
Gitlab
.
config
.
gitlab
.
relative_url_root
,
'/-/cable'
)
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
config
.
action_cable
.
worker_pool_size
=
Gitlab
.
config
.
action_cable
.
worker_pool_size
end
end
...
...
lib/gitlab/runtime.rb
View file @
57cdb4c5
...
@@ -37,7 +37,7 @@ module Gitlab
...
@@ -37,7 +37,7 @@ module Gitlab
end
end
def
puma?
def
puma?
!!
defined?
(
::
Puma
)
!!
defined?
(
::
Puma
)
&&
!
defined?
(
ACTION_CABLE_SERVER
)
end
end
# For unicorn, we need to check for actual server instances to avoid false positives.
# For unicorn, we need to check for actual server instances to avoid false positives.
...
@@ -70,11 +70,11 @@ module Gitlab
...
@@ -70,11 +70,11 @@ module Gitlab
end
end
def
web_server?
def
web_server?
puma?
||
unicorn?
puma?
||
unicorn?
||
action_cable?
end
end
def
action_cable?
def
action_cable?
web_server?
&&
(
!!
defined?
(
ACTION_CABLE_SERVER
)
||
Gitlab
.
config
.
action_cable
.
in_app
)
!!
defined?
(
ACTION_CABLE_SERVER
)
end
end
def
multi_threaded?
def
multi_threaded?
...
@@ -82,21 +82,19 @@ module Gitlab
...
@@ -82,21 +82,19 @@ module Gitlab
end
end
def
max_threads
def
max_threads
threads
=
1
# main thread
main_thread
=
1
if
puma?
if
action_cable?
threads
+=
Puma
.
cli_config
.
options
[
:max_threads
]
Gitlab
::
Application
.
config
.
action_cable
.
worker_pool_size
elsif
puma?
Puma
.
cli_config
.
options
[
:max_threads
]
elsif
sidekiq?
elsif
sidekiq?
# An extra thread for the poller in Sidekiq Cron:
# An extra thread for the poller in Sidekiq Cron:
# https://github.com/ondrejbartas/sidekiq-cron#under-the-hood
# https://github.com/ondrejbartas/sidekiq-cron#under-the-hood
threads
+=
Sidekiq
.
options
[
:concurrency
]
+
1
Sidekiq
.
options
[
:concurrency
]
+
1
end
else
0
if
action_cable?
end
+
main_thread
threads
+=
Gitlab
.
config
.
action_cable
.
worker_pool_size
end
threads
end
end
end
end
end
end
...
...
spec/lib/gitlab/runtime_spec.rb
View file @
57cdb4c5
...
@@ -48,45 +48,18 @@ describe Gitlab::Runtime do
...
@@ -48,45 +48,18 @@ describe Gitlab::Runtime do
before
do
before
do
stub_const
(
'::Puma'
,
puma_type
)
stub_const
(
'::Puma'
,
puma_type
)
allow
(
puma_type
).
to
receive_message_chain
(
:cli_config
,
:options
).
and_return
(
max_threads:
2
)
allow
(
puma_type
).
to
receive_message_chain
(
:cli_config
,
:options
).
and_return
(
max_threads:
2
)
stub_config
(
action_cable:
{
in_app:
false
})
end
end
it_behaves_like
"valid runtime"
,
:puma
,
3
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
end
context
"unicorn"
do
context
"unicorn"
do
before
do
before
do
stub_const
(
'::Unicorn'
,
Module
.
new
)
stub_const
(
'::Unicorn'
,
Module
.
new
)
stub_const
(
'::Unicorn::HttpServer'
,
Class
.
new
)
stub_const
(
'::Unicorn::HttpServer'
,
Class
.
new
)
stub_config
(
action_cable:
{
in_app:
false
})
end
end
it_behaves_like
"valid runtime"
,
:unicorn
,
1
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
end
context
"sidekiq"
do
context
"sidekiq"
do
...
@@ -132,4 +105,17 @@ describe Gitlab::Runtime do
...
@@ -132,4 +105,17 @@ describe Gitlab::Runtime do
it_behaves_like
"valid runtime"
,
:rails_runner
,
1
it_behaves_like
"valid runtime"
,
:rails_runner
,
1
end
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
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