Skip to content

Commit

Permalink
Improve startup log stream
Browse files Browse the repository at this point in the history
Signed-off-by: Dramelac <[email protected]>
  • Loading branch information
Dramelac committed Jan 18, 2025
1 parent 040a170 commit 38d0460
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion exegol/config/ConstantConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class ConstantConfig:
"""Constant parameters information"""
# Exegol Version
version: str = "4.3.9"
version: str = "4.3.10b1"

# Exegol documentation link
documentation: str = "https://exegol.rtfd.io/"
Expand Down
4 changes: 2 additions & 2 deletions exegol/model/ContainerConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ def __init__(self, container: Optional[Container] = None):
self.__labels: Dict[str, str] = {}
self.__ports: Dict[str, Optional[Union[int, Tuple[str, int], List[int], List[Dict[str, Union[int, str]]]]]] = {}
self.__extra_host: Dict[str, str] = {}
self.interactive: bool = True
self.tty: bool = True
self.interactive: bool = False
self.tty: bool = False
self.shm_size: str = self.__default_shm_size
self.__workspace_custom_path: Optional[str] = None
self.__workspace_dedicated_path: Optional[str] = None
Expand Down
17 changes: 9 additions & 8 deletions exegol/utils/ContainerLogStream.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,15 @@ def __next__(self):
assert self.__data_stream is not None
# Parsed the data stream to extract characters and merge them into a line.
for streamed_char in self.__data_stream:
self.__enable_timeout = False # disable timeout if the container is up-to-date and support console logging
# Add new char to the buffer + Unify \r\n to \n
self.__line_buffer += streamed_char.replace(b'\r\n', b'\n')
# When detecting an end of line, the buffer is returned as a single line.
if (streamed_char == b'\r' or streamed_char == b'\n') and len(self.__line_buffer) > 0:
line = self.__line_buffer.decode('utf-8').strip()
self.__line_buffer = b""
return line
else:
self.__enable_timeout = False # disable timeout if the container is up-to-date and support console logging
self.__line_buffer += streamed_char # add characters to the line buffer
if b'\n' in self.__line_buffer:
lines = self.__line_buffer.split(b'\n')
self.__line_buffer = b'\n'.join(lines[1:]) if len(lines) > 1 else b''
if len(lines[0]) > 0:
return lines[0].decode('utf-8').strip()
# When the data stream is empty, check if a timeout condition apply
if self.__enable_timeout and self.__until_date >= self.__timeout_date:
logger.debug("Container log stream timed-out")
Expand All @@ -64,5 +65,5 @@ def __next__(self):
# Prepare the next iteration to fetch next logs
self.__data_stream = None
self.__since_date = self.__until_date
time.sleep(0.5) # Wait for more logs
time.sleep(1) # Wait for more logs
self.__until_date = datetime.now()
3 changes: 2 additions & 1 deletion exegol/utils/imgsync/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ function endless() {
# Entrypoint for the container, in order to have a process hanging, to keep the container alive
# Alternative to running bash/zsh/whatever as entrypoint, which is longer to start and to stop and to very clean
# shellcheck disable=SC2162
read -u 2 # read from stderr => endlessly wait effortlessly
mkfifo -m 000 /tmp/.entrypoint # Create an empty fifo for sleep by read.
read <> /tmp/.entrypoint # read from /tmp/.entrypoint => endlessly wait without sub-process or need for TTY option
}

function shutdown() {
Expand Down

0 comments on commit 38d0460

Please sign in to comment.