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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
106f3db9
Commit
106f3db9
authored
Apr 28, 2017
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor timeout code
parent
b325d4a6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
8 deletions
+17
-8
spec/unicorn/unicorn_spec.rb
spec/unicorn/unicorn_spec.rb
+17
-8
No files found.
spec/unicorn/unicorn_spec.rb
View file @
106f3db9
...
...
@@ -39,14 +39,7 @@ describe 'Unicorn' do
cmd
=
%W[unicorn -E test -c
#{
config_path
}
#{
Rails
.
root
.
join
(
'config.ru'
)
}
]
@unicorn_master_pid
=
spawn
(
*
cmd
)
120
.
times
do
break
if
File
.
exist?
(
ready_file
)
pid
=
Process
.
waitpid
(
@unicorn_master_pid
,
Process
::
WNOHANG
)
raise
"unicorn failed to boot:
#{
$?
}
"
unless
pid
.
nil?
sleep
1
end
wait_unicorn_boot!
(
@unicorn_master_pid
,
ready_file
)
WebMock
.
allow_net_connect!
end
...
...
@@ -73,7 +66,23 @@ describe 'Unicorn' do
Process
.
kill
(
'TERM'
,
@unicorn_master_pid
)
end
def
wait_unicorn_boot!
(
master_pid
,
ready_file
)
# Unicorn should boot in under 60 seconds so 120 seconds seems like a good timeout.
timeout
=
120
timeout
.
times
do
return
if
File
.
exist?
(
ready_file
)
pid
=
Process
.
waitpid
(
master_pid
,
Process
::
WNOHANG
)
raise
"unicorn failed to boot:
#{
$?
}
"
unless
pid
.
nil?
sleep
1
end
raise
"unicorn boot timed out after
#{
timeout
}
seconds"
end
def
pid_gone?
(
pid
)
# Worker termination should take less than a second. That makes 10
# seconds a generous timeout.
10
.
times
do
begin
Process
.
kill
(
0
,
pid
)
...
...
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