Skip to content

Add WineBootTimeout to Config #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions AstroTuxLauncher.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class LauncherConfig:
AstroServerPath: str = "AstroneerServer" # The path, where the Astroneer DS installation should reside
OverrideWinePath: Optional[str] = field(metadata=config(exclude=ExcludeIfNone), default=None) # Path to wine executable, only used, if set
WinePrefixPath: str = "winepfx" # The path, where the Wine prefix should be stored
WineBootTimeout: int = 30 # The time (in seconds) that Wine will wait when running *Wineboot* before it times out
LogPath: str = "logs" # The path where logs should be saved

PlayfabAPIInterval: int = 2 # Time to wait between Playfab API requests
Expand Down Expand Up @@ -312,7 +313,7 @@ def update_wine_prefix(self):
"""

LOGGER.debug("Ensuring WINE prefix is setup...")

timeout = self.config.WineBootTimeout
cmd = [self.wineexec, "wineboot"]
env = os.environ.copy()

Expand All @@ -326,16 +327,23 @@ def update_wine_prefix(self):
LOGGER.debug(f"Executing command '{' '.join(cmd)}' in WINE prefix '{self.config.WinePrefixPath}'...")

try:
wineprocess = subprocess.Popen(cmd, env=env, cwd=self.config.AstroServerPath, stderr=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=True)
code = wineprocess.wait(timeout=30)
except TimeoutError:
LOGGER.debug("Wine process took longer than 30 seconds, aborting")
wineprocess = subprocess.Popen(
cmd,
env=env,
cwd=self.config.AstroServerPath,
stderr=subprocess.PIPE,
stdout=subprocess.PIPE,
close_fds=True
)
code = wineprocess.wait(timeout=timeout) # Use timeout defined from the config value
except subprocess.TimeoutExpired:
LOGGER.debug(f"Wine process took longer than {timeout} seconds, aborting")
return False
except Exception as e:
LOGGER.error(f"Error occured during updating of wine prefix: {str(e)}")
LOGGER.error(f"Error occurred during updating of wine prefix: {str(e)}")
return False

return code == 0
return code == 0

def check_network_config(self):
if not self.dedicatedserver:
Expand Down Expand Up @@ -613,4 +621,4 @@ def exit(self, graceful=False, reason=None):

raise

LOGGER.info("Goodbye!")
LOGGER.info("Goodbye!")
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ OverrideWinePath = # Not set by default
# used for running the server should reside
WinePrefixPath = "winepfx"

# The time (in seconds) that Wine will wait before closing out during Prefix check and creation
# Default value: 30
WineBootTimeout = 30

# (Path as String) Relative or absolute path to the directory where the log files should reside
LogPath = "logs"

Expand Down