diff --git a/CHANGELOG.md b/CHANGELOG.md index ca594108..44c21828 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/assets/src/server/ballisticacore_server.py b/assets/src/server/ballisticacore_server.py index c81a0527..f1fd5846 100755 --- a/assets/src/server/ballisticacore_server.py +++ b/assets/src/server/ballisticacore_server.py @@ -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 diff --git a/docs/ba_module.md b/docs/ba_module.md index 5406c71a..1fb63759 100644 --- a/docs/ba_module.md +++ b/docs/ba_module.md @@ -1,5 +1,5 @@ -
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 let me know. Happy modding!