Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
allgo
allgo
Commits
81bc5a5c
Commit
81bc5a5c
authored
Apr 11, 2017
by
BAIRE Anthony
Browse files
wait for the mysql server to be ready (at controller startup)
parent
5fbbcd64
Changes
1
Hide whitespace changes
Inline
Side-by-side
controller/controller.py
View file @
81bc5a5c
...
...
@@ -1541,6 +1541,26 @@ class DockerController:
self
.
check_db
()
@
asyncio
.
coroutine
def
db_startup
(
self
):
log
.
info
(
"wait until the db server is ready"
)
ses
=
self
.
session
while
True
:
with
contextlib
.
suppress
(
sqlalchemy
.
exc
.
OperationalError
):
log
.
debug
(
"db ping"
)
with
ses
.
begin
():
ses
.
execute
(
"SELECT 1"
)
break
with
contextlib
.
suppress
(
asyncio
.
TimeoutError
):
yield
from
asyncio
.
wait_for
(
asyncio
.
shield
(
self
.
_shutdown_requested
),
10
)
return
log
.
info
(
"db server ready"
)
self
.
check_db
(
startup
=
True
)
def
check_db
(
self
,
*
,
startup
=
False
):
log
.
debug
(
"check_db(startup=%r)"
,
startup
)
try
:
...
...
@@ -1592,7 +1612,7 @@ class DockerController:
loop
.
add_signal_handler
(
signal
.
SIGINT
,
self
.
shutdown
)
loop
.
add_reader
(
self
.
sock
,
self
.
_sock_callback
)
self
.
check_
db
(
startup
=
True
)
yield
from
self
.
db
_
startup
(
)
try
:
yield
from
self
.
_shutdown_requested
finally
:
...
...
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