Fix process not cleanly exiting when it was supposed to

This commit is contained in:
zontreck 2024-06-05 20:28:19 -07:00
parent 26434a9123
commit 6574888344
4 changed files with 32 additions and 7 deletions

View file

@ -1,5 +1,6 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:io';
import 'package:libac_dart/nbt/NbtUtils.dart'; import 'package:libac_dart/nbt/NbtUtils.dart';
import 'package:libac_dart/nbt/Stream.dart'; import 'package:libac_dart/nbt/Stream.dart';
@ -303,6 +304,7 @@ class C2SUploadSettingsPacket implements IPacket {
// Stop packet server // Stop packet server
PacketServer.socket!.close(); PacketServer.socket!.close();
timer.cancel(); timer.cancel();
exit(0);
}); // We give time to allow the server to shut down gracefully. }); // We give time to allow the server to shut down gracefully.
} }

View file

@ -21,6 +21,26 @@ class ModManagerState extends State<ModManager> {
appBar: AppBar( appBar: AppBar(
title: Text("Conan Exiles Server Manager - Mod Manager"), title: Text("Conan Exiles Server Manager - Mod Manager"),
backgroundColor: Color.fromARGB(255, 100, 0, 0), backgroundColor: Color.fromARGB(255, 100, 0, 0),
actions: [
IconButton(
onPressed: () {
for (Mod M in settings.inst!.mods) {
M.enabled = false;
}
setState(() {});
},
icon: Icon(Icons.swipe_down)),
IconButton(
onPressed: () {
for (Mod M in settings.inst!.mods) {
M.enabled = true;
}
setState(() {});
},
icon: Icon(Icons.swipe_up))
],
), ),
body: ReorderableListView.builder( body: ReorderableListView.builder(
onReorder: (oldIndex, newIndex) { onReorder: (oldIndex, newIndex) {

View file

@ -224,6 +224,7 @@ class StateMachine {
if (settings.inst!.pterodactylMode) { if (settings.inst!.pterodactylMode) {
// Shut down the server processes now // Shut down the server processes now
PacketServer.socket!.close(); PacketServer.socket!.close();
exit(0);
} else { } else {
resetKillswitch(); resetKillswitch();
SessionData.timer = settings.inst!.timer.time.copy(); SessionData.timer = settings.inst!.timer.time.copy();
@ -297,12 +298,14 @@ class StateMachine {
} }
} }
if (updatedMods.isNotEmpty) {
settings.sendRconCommand( settings.sendRconCommand(
"broadcast The server will be going down for a restart in 5 minutes. The following mods have been updated: ${updatedMods.join(', ')}"); "broadcast The server will be going down for a restart in 5 minutes. The following mods have been updated: ${updatedMods.join(', ')}");
SessionData.timer.apply((5 * 60)); SessionData.timer.apply((5 * 60));
print( print(
"Scheduling restart for mod updates: ${updatedMods.join(', ')}"); "Scheduling restart for mod updates: ${updatedMods.join(', ')}");
SessionData.enableRestartTimer = true; SessionData.enableRestartTimer = true;
}
}); });
} }

View file

@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts # In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix. # of the product and file versions while build-number is used as the build suffix.
version: 1.0.0+1 version: 1.1.0+1
environment: environment:
sdk: '>=3.1.4 <4.0.0' sdk: '>=3.1.4 <4.0.0'