mirror of
https://github.com/RYDE-WORK/ballistica.git
synced 2026-01-23 07:23:19 +08:00
Additional server cleanup
This commit is contained in:
parent
ad82e1badf
commit
2112db7bfe
@ -1,4 +1,4 @@
|
||||
### 1.6.0 (20279)
|
||||
### 1.6.0 (20308)
|
||||
- Added private parties functionality (cloud hosted parties with associated codes making it easier to play with friends)
|
||||
- The meta subsystem now enables new plugins by default in headless builds.
|
||||
- Added option to save party in Manual tab
|
||||
@ -11,6 +11,7 @@
|
||||
- Fixed an issue where click locations on scaled text fields could be incorrectly calculated.
|
||||
- Server-wrapper improvements allowing config path and ba_root path to be passed explicitly.
|
||||
- Binary -cfgdir option now properly allows any path, not just './ba_root'.
|
||||
- Additional server-wrapper options such as disabling auto-restart and automatic restarts on config file changes.
|
||||
|
||||
### 1.5.29 (20246)
|
||||
- Exposed ba method/class initing in public C++ layer.
|
||||
|
||||
@ -81,12 +81,9 @@ class ServerManagerApp:
|
||||
self._config_mtime: Optional[float] = None
|
||||
self._last_config_mtime_check_time: Optional[float] = None
|
||||
self._should_report_subprocess_error = False
|
||||
self._periodic_restart_minutes = 360.0
|
||||
self._running = False
|
||||
self._subprocess: Optional[subprocess.Popen[bytes]] = None
|
||||
self._launch_time = time.time()
|
||||
self._subprocess_launch_time: Optional[float] = None
|
||||
self._subprocess_sent_periodic_restart = False
|
||||
self._subprocess_sent_config_auto_restart = False
|
||||
self._subprocess_sent_clean_exit = False
|
||||
self._subprocess_sent_unclean_exit = False
|
||||
@ -109,15 +106,6 @@ class ServerManagerApp:
|
||||
dataclass_validate(value)
|
||||
self._config = value
|
||||
|
||||
@property
|
||||
def periodic_restart_minutes(self) -> Optional[float]:
|
||||
"""The time between server restarts when running indefinitely.
|
||||
|
||||
Restarting the server periodically can minimize the effect of
|
||||
memory leaks or other built-up cruft.
|
||||
"""
|
||||
return self._periodic_restart_minutes
|
||||
|
||||
def _prerun(self) -> None:
|
||||
"""Common code at the start of any run."""
|
||||
|
||||
@ -690,18 +678,7 @@ class ServerManagerApp:
|
||||
assert current_thread() is self._subprocess_thread
|
||||
assert self._subprocess_launch_time is not None
|
||||
now = time.time()
|
||||
sincelaunch = now - self._subprocess_launch_time
|
||||
|
||||
# If we're doing auto-restarts, restart periodically to freshen up.
|
||||
if (self._auto_restart and sincelaunch >
|
||||
(self._periodic_restart_minutes * 60.0)
|
||||
and not self._subprocess_sent_periodic_restart):
|
||||
print(f'{Clr.CYN}periodic_restart_minutes'
|
||||
f' ({self._periodic_restart_minutes})'
|
||||
f' elapsed; requesting soft'
|
||||
f' restart.{Clr.RST}')
|
||||
self.restart(immediate=False)
|
||||
self._subprocess_sent_periodic_restart = True
|
||||
minutes_since_launch = (now - self._subprocess_launch_time) / 60.0
|
||||
|
||||
# If we're doing auto-restart with config changes, handle that.
|
||||
if (self._auto_restart and self._config_auto_restart
|
||||
@ -721,14 +698,18 @@ class ServerManagerApp:
|
||||
self._subprocess_sent_config_auto_restart = True
|
||||
|
||||
# Attempt clean exit if our clean-exit-time passes.
|
||||
# (and enforce a 6 hour max if not provided)
|
||||
clean_exit_minutes = 360.0
|
||||
if self._config.clean_exit_minutes is not None:
|
||||
elapsed = (time.time() - self._launch_time) / 60.0
|
||||
if (elapsed > self._config.clean_exit_minutes
|
||||
clean_exit_minutes = min(clean_exit_minutes,
|
||||
self._config.clean_exit_minutes)
|
||||
if clean_exit_minutes is not None:
|
||||
if (minutes_since_launch > clean_exit_minutes
|
||||
and not self._subprocess_sent_clean_exit):
|
||||
opname = 'restart' if self._auto_restart else 'shutdown'
|
||||
print(f'{Clr.CYN}clean_exit_minutes'
|
||||
f' ({self._config.clean_exit_minutes})'
|
||||
f' elapsed; requesting immediate'
|
||||
f' ({clean_exit_minutes})'
|
||||
f' elapsed; requesting soft'
|
||||
f' {opname}.{Clr.RST}')
|
||||
if self._auto_restart:
|
||||
self.restart(immediate=False)
|
||||
@ -737,13 +718,17 @@ class ServerManagerApp:
|
||||
self._subprocess_sent_clean_exit = True
|
||||
|
||||
# Attempt unclean exit if our unclean-exit-time passes.
|
||||
# (and enforce a 7 hour max if not provided)
|
||||
unclean_exit_minutes = 420.0
|
||||
if self._config.unclean_exit_minutes is not None:
|
||||
elapsed = (time.time() - self._launch_time) / 60.0
|
||||
if (elapsed > self._config.unclean_exit_minutes
|
||||
unclean_exit_minutes = min(unclean_exit_minutes,
|
||||
self._config.unclean_exit_minutes)
|
||||
if unclean_exit_minutes is not None:
|
||||
if (minutes_since_launch > unclean_exit_minutes
|
||||
and not self._subprocess_sent_unclean_exit):
|
||||
opname = 'restart' if self._auto_restart else 'shutdown'
|
||||
print(f'{Clr.CYN}unclean_exit_minutes'
|
||||
f' ({self._config.unclean_exit_minutes})'
|
||||
f' ({unclean_exit_minutes})'
|
||||
f' elapsed; requesting immediate'
|
||||
f' {opname}.{Clr.RST}')
|
||||
if self._auto_restart:
|
||||
@ -755,7 +740,6 @@ class ServerManagerApp:
|
||||
def _reset_subprocess_vars(self) -> None:
|
||||
self._subprocess = None
|
||||
self._subprocess_launch_time = None
|
||||
self._subprocess_sent_periodic_restart = False
|
||||
self._subprocess_sent_config_auto_restart = False
|
||||
self._subprocess_sent_clean_exit = False
|
||||
self._subprocess_sent_unclean_exit = False
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<!-- THIS FILE IS AUTO GENERATED; DO NOT EDIT BY HAND -->
|
||||
<h4><em>last updated on 2021-02-25 for Ballistica version 1.6.0 build 20307</em></h4>
|
||||
<h4><em>last updated on 2021-02-25 for Ballistica version 1.6.0 build 20308</em></h4>
|
||||
<p>This page documents the Python classes and functions in the 'ba' module,
|
||||
which are the ones most relevant to modding in Ballistica. If you come across something you feel should be included here or could be better explained, please <a href="mailto:support@froemling.net">let me know</a>. Happy modding!</p>
|
||||
<hr>
|
||||
|
||||
@ -91,26 +91,24 @@ class ServerConfig:
|
||||
# http://bombsquadgame.com/accountquery?id=ACCOUNT_ID_HERE
|
||||
stats_url: Optional[str] = None
|
||||
|
||||
# If present, the server manager will attempt to gracefully exit after
|
||||
# If present, the server subprocess will attempt to gracefully exit after
|
||||
# this amount of time. A graceful exit can occur at the end of a series
|
||||
# or other opportune time.
|
||||
# Servers with no exit conditions set will run indefinitely, though the
|
||||
# server binary will be restarted periodically to clear any memory
|
||||
# leaks or other bad state.
|
||||
# or other opportune time. Server-managers set to auto-restart (the
|
||||
# default) will then spin up a fresh subprocess. This mechanism can be
|
||||
# useful to clear out any memory leaks or other accumulated bad state
|
||||
# in the server subprocess.
|
||||
clean_exit_minutes: Optional[float] = None
|
||||
|
||||
# If present, the server manager will shut down immediately after this
|
||||
# If present, the server subprocess will shut down immediately after this
|
||||
# amount of time. This can be useful as a fallback for clean_exit_time.
|
||||
# Servers with no exit conditions set will run indefinitely, though the
|
||||
# server binary will be restarted periodically to clear any memory
|
||||
# leaks or other bad state.
|
||||
# The server manager will then spin up a fresh server subprocess if
|
||||
# auto-restart is enabled (the default).
|
||||
unclean_exit_minutes: Optional[float] = None
|
||||
|
||||
# If present, the server will shut down immediately if this amount of
|
||||
# time passes with no activity from any players.
|
||||
# Servers with no exit conditions set will run indefinitely, though the
|
||||
# server binary will be restarted periodically to clear any memory
|
||||
# leaks or other bad state.
|
||||
# If present, the server subprocess will shut down immediately if this
|
||||
# amount of time passes with no activity from any players. The server
|
||||
# manager will then spin up a fresh server subprocess if
|
||||
# auto-restart is enabled (the default).
|
||||
idle_exit_minutes: Optional[float] = None
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user