restart method

Future<void> restart()

Restarts the server by stopping and starting it again. This method performs a graceful restart by:

  1. Stopping the current server instance with force flag
  2. Waiting for 2 seconds to ensure proper cleanup
  3. Starting the server again with the same configuration Any errors during the stop process are logged but don't prevent the restart. This is useful for applying configuration changes or recovering from errors.

Implementation

Future<void> restart() async {
  try {
    await stop(force: true);
  } catch (e) {
    Console.e("Error on stop server: $e");
  }
  await Future.delayed(Duration(seconds: 2));
  await start();
}