Commit 9dbe3cec authored by Sebastien Petitdemange's avatar Sebastien Petitdemange

Merge branch 'fix-tangodb-tests' into 'master'

Fix Tango DB issues during tests and Tango DB output processing in Beacon

See merge request bliss/bliss!1265
parents 2ed9cddb 62d73cde
......@@ -775,8 +775,6 @@ def main(args=None):
# Tango databaseds
if _options.tango_port > 0:
# Stdout pipe
_tlog.info("Database started on port: %s", _options.tango_port)
tango_rp, tango_wp = os.pipe()
# Environment
env = dict(os.environ)
......@@ -828,7 +826,7 @@ def main(args=None):
# Safe context
try:
fd_list = [udp, tcp, uds, rp, sig_read] + ([tango_rp] if tango_rp else [])
fd_list = filter(None, [udp, tcp, uds, rp, sig_read, tango_rp])
logger = {rp: _rlog, tango_rp: _tlog}
udp_reply = b"%s|%d" % (socket.gethostname().encode(), beacon_port)
......@@ -877,16 +875,27 @@ def main(args=None):
# Log the message properly
if msg:
logger.get(fd, _log).info(msg.decode())
# Tango DB is not alive
elif fd == tango_rp:
fd_list.remove(tango_rp)
os.close(tango_rp)
logger.get(fd, _log).warning("database exit")
rp_processing = gevent.spawn(do_rp_processing, rp)
def do_tango_rp_processing(fd):
while True:
msg = gevent.os.tp_read(fd, 8192)
if msg:
logger.get(fd, _log).info(msg.decode())
if tango_rp:
tango_rp_processing = gevent.spawn(do_tango_rp_processing, tango_rp)
else:
tango_rp_processing = None
# ==== Define processes list ============
proc_list = [udp_processing, tcp_processing, rp_processing]
proc_list = list(
filter(
None,
[udp_processing, tcp_processing, rp_processing, tango_rp_processing],
)
)
# ==== UDS case (UNIX only) ============
if sys.platform not in ["win32", "cygwin"]:
......
"""Run the tango.databaseds.database server with bliss db_access."""
import sys
import argparse
from tango.databaseds import db_access
from tango.databaseds.database import main as base_main
......@@ -14,6 +15,14 @@ def main(args=None):
from tango.databaseds.db_access import beacon
assert beacon.__file__.startswith(local_db_access.__path__[0])
# Display message (used for synchronization with parent process)
p = argparse.ArgumentParser()
p.add_argument("--port", type=int, dest="port")
known_args, _ = p.parse_known_args(sys.argv)
print(f"database started on port: {known_args.port}")
sys.stdout.flush()
# Run
base_main(args)
......
......@@ -140,10 +140,7 @@ def ports(beacon_directory):
"--webapp_port=%d" % ports.cfgapp_port,
]
proc = subprocess.Popen(BEACON + args, stderr=subprocess.PIPE)
wait_for(
proc.stderr,
"The server is now ready to accept connections at {}".format(redis_uds),
)
wait_for(proc.stderr, "database started on port")
os.environ["TANGO_HOST"] = "localhost:%d" % ports.tango_port
os.environ["BEACON_HOST"] = "localhost:%d" % ports.beacon_port
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment