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
06719b57
Commit
06719b57
authored
May 21, 2021
by
Aleksei Lipniagov
Committed by
Matthias Käppler
May 21, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove Unicorn support: delete UnicornHttpServer mixin
parent
5411c14b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
156 deletions
+3
-156
config/initializers/cluster_events_before_phased_restart.rb
config/initializers/cluster_events_before_phased_restart.rb
+3
-5
lib/gitlab/cluster/mixins/unicorn_http_server.rb
lib/gitlab/cluster/mixins/unicorn_http_server.rb
+0
-34
spec/lib/gitlab/cluster/mixins/unicorn_http_server_spec.rb
spec/lib/gitlab/cluster/mixins/unicorn_http_server_spec.rb
+0
-117
No files found.
config/initializers/cluster_events_before_phased_restart.rb
View file @
06719b57
...
...
@@ -7,8 +7,6 @@
#
# Follow-up the issue: https://gitlab.com/gitlab-org/gitlab/issues/34107
if
Gitlab
::
Runtime
.
puma?
Puma
::
Cluster
.
prepend
(
::
Gitlab
::
Cluster
::
Mixins
::
PumaCluster
)
elsif
Gitlab
::
Runtime
.
unicorn?
Unicorn
::
HttpServer
.
prepend
(
::
Gitlab
::
Cluster
::
Mixins
::
UnicornHttpServer
)
end
return
unless
Gitlab
::
Runtime
.
puma?
Puma
::
Cluster
.
prepend
(
::
Gitlab
::
Cluster
::
Mixins
::
PumaCluster
)
lib/gitlab/cluster/mixins/unicorn_http_server.rb
deleted
100644 → 0
View file @
5411c14b
# frozen_string_literal: true
module
Gitlab
module
Cluster
module
Mixins
module
UnicornHttpServer
def
self
.
prepended
(
base
)
unless
base
.
method_defined?
(
:reexec
)
&&
base
.
method_defined?
(
:stop
)
raise
'missing method Unicorn::HttpServer#reexec or Unicorn::HttpServer#stop'
end
end
def
reexec
Gitlab
::
Cluster
::
LifecycleEvents
.
do_before_graceful_shutdown
super
end
# The stop on non-graceful shutdown is executed twice:
# `#stop(false)` and `#stop`.
#
# The first stop will wipe-out all workers, so we need to check
# the flag and a list of workers
def
stop
(
graceful
=
true
)
if
graceful
&&
@workers
.
any?
# rubocop:disable Gitlab/ModuleWithInstanceVariables
Gitlab
::
Cluster
::
LifecycleEvents
.
do_before_graceful_shutdown
end
super
end
end
end
end
end
spec/lib/gitlab/cluster/mixins/unicorn_http_server_spec.rb
deleted
100644 → 0
View file @
5411c14b
# frozen_string_literal: true
require
'spec_helper'
# For easier debugging set `UNICORN_DEBUG=1`
RSpec
.
describe
Gitlab
::
Cluster
::
Mixins
::
UnicornHttpServer
do
before
do
stub_const
(
'UNICORN_STARTUP_TIMEOUT'
,
30
)
end
context
'when running Unicorn'
do
using
RSpec
::
Parameterized
::
TableSyntax
where
(
:signal
,
:exitstatus
,
:termsig
)
do
# executes phased restart block
:USR2
|
140
|
nil
:QUIT
|
140
|
nil
# does not execute phased restart block
:INT
|
0
|
nil
:TERM
|
0
|
nil
end
with_them
do
it
'properly handles process lifecycle'
do
with_unicorn
(
workers:
1
)
do
|
pid
|
Process
.
kill
(
signal
,
pid
)
child_pid
,
child_status
=
Process
.
wait2
(
pid
)
expect
(
child_pid
).
to
eq
(
pid
)
expect
(
child_status
.
exitstatus
).
to
eq
(
exitstatus
)
expect
(
child_status
.
termsig
).
to
eq
(
termsig
)
end
end
end
end
private
def
with_unicorn
(
workers
:,
timeout:
UNICORN_STARTUP_TIMEOUT
)
with_unicorn_configs
(
workers:
workers
)
do
|
unicorn_rb
,
config_ru
|
cmdline
=
[
"bundle"
,
"exec"
,
"unicorn"
,
"-I"
,
Rails
.
root
.
to_s
,
"-c"
,
unicorn_rb
,
config_ru
]
IO
.
popen
(
cmdline
)
do
|
process
|
# wait for process to start:
# I, [2019-10-15T13:21:27.565225 #3089] INFO -- : master process ready
wait_for_output
(
process
,
/master process ready/
,
timeout:
timeout
)
consume_output
(
process
)
yield
(
process
.
pid
)
ensure
begin
Process
.
kill
(
:KILL
,
process
.
pid
)
rescue
Errno
::
ESRCH
end
end
end
end
def
with_unicorn_configs
(
workers
:)
Dir
.
mktmpdir
do
|
dir
|
File
.
write
"
#{
dir
}
/unicorn.rb"
,
<<-
EOF
require './lib/gitlab/cluster/lifecycle_events'
require './lib/gitlab/cluster/mixins/unicorn_http_server'
worker_processes
#{
workers
}
listen "127.0.0.1:0"
preload_app true
Unicorn::HttpServer.prepend(
#{
described_class
}
)
mutex = Mutex.new
Gitlab::Cluster::LifecycleEvents.on_before_blackout_period do
mutex.synchronize do
exit(140)
end
end
# redirect stderr to stdout
$stderr.reopen($stdout)
EOF
File
.
write
"
#{
dir
}
/config.ru"
,
<<-
EOF
run -> (env) { [404, {}, ['']] }
EOF
yield
(
"
#{
dir
}
/unicorn.rb"
,
"
#{
dir
}
/config.ru"
)
end
end
def
wait_for_output
(
process
,
output
,
timeout
:)
Timeout
.
timeout
(
timeout
)
do
loop
do
line
=
process
.
readline
puts
"UNICORN_DEBUG:
#{
line
}
"
if
ENV
[
'UNICORN_DEBUG'
]
break
if
line
=~
output
end
end
end
def
consume_output
(
process
)
Thread
.
new
do
loop
do
line
=
process
.
readline
puts
"UNICORN_DEBUG:
#{
line
}
"
if
ENV
[
'UNICORN_DEBUG'
]
end
rescue
StandardError
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