While port_filename is useful for automation, it isn't essential when
using lttng_live_server.py manually. Make that argument non-required.
Also, print a message indicating the port used to listen, which is handy
for interactive use.
Change how lttng_live_server.py is invoked to redirect stdout to stderr,
hopefully avoiding messing up the tap output format.
Change-Id: Ie185ced440c51fb1bb8355553f7b4a7725a13542
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10896
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
def __init__(
self,
port: Optional[int],
def __init__(
self,
port: Optional[int],
+ port_filename: Optional[str],
tracing_session_descriptors: Iterable[LttngTracingSessionDescriptor],
max_query_data_response_size: Optional[int],
):
tracing_session_descriptors: Iterable[LttngTracingSessionDescriptor],
max_query_data_response_size: Optional[int],
):
# Port 0: OS assigns an unused port
serv_addr = ("localhost", port if port is not None else 0)
self._sock.bind(serv_addr)
# Port 0: OS assigns an unused port
serv_addr = ("localhost", port if port is not None else 0)
self._sock.bind(serv_addr)
- self._write_port_to_file(port_filename)
+
+ if port_filename is not None:
+ self._write_port_to_file(port_filename)
+
+ print("Listening on port {}".format(self._server_port))
parser.add_argument(
"--port-filename",
help="The final port file. This file is present when the server is ready to receive connection.",
parser.add_argument(
"--port-filename",
help="The final port file. This file is present when the server is ready to receive connection.",
)
parser.add_argument(
"--max-query-data-response-size",
)
parser.add_argument(
"--max-query-data-response-size",
)
port = args.port # type: int | None
)
port = args.port # type: int | None
- port_filename = args.port_filename # type: str
+ port_filename = args.port_filename # type: str | None
max_query_data_response_size = args.max_query_data_response_size # type: int | None
LttngLiveServer(port, port_filename, sessions, max_query_data_response_size)
max_query_data_response_size = args.max_query_data_response_size # type: int | None
LttngLiveServer(port, port_filename, sessions, max_query_data_response_size)
diag "$BT_TESTS_PYTHON_BIN $server_script --port-file $port_file --trace-path-prefix $trace_dir_native $server_args"
echo "$server_args" | run_python xargs "$BT_TESTS_PYTHON_BIN" "$server_script" \
--port-file "$port_file" \
diag "$BT_TESTS_PYTHON_BIN $server_script --port-file $port_file --trace-path-prefix $trace_dir_native $server_args"
echo "$server_args" | run_python xargs "$BT_TESTS_PYTHON_BIN" "$server_script" \
--port-file "$port_file" \
- --trace-path-prefix "$trace_dir_native" &
+ --trace-path-prefix "$trace_dir_native" 1>&2 &
# write PID to file
echo $! > "$pid_file"
# write PID to file
echo $! > "$pid_file"