Skip to content

Commit a132c57

Browse files
committed
Fix remote tool not exiting, log file location, fix backups failing after server stops. Updated docs. Ready to release v1.1.
1 parent b167720 commit a132c57

File tree

6 files changed

+21
-3
lines changed

6 files changed

+21
-3
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,11 @@ Every Wednesday at 01:50, except if it is the 1st of the month:
153153
"Weekdays": "All"
154154
}
155155
]
156-
```
156+
```
157+
158+
159+
### Known Issues
160+
- Starting the remote tool before the SMSM service is ready will cause it to connect, but will not be able to send commands, and will cause the service to lose its server process.
161+
- Recommended workaround: Do not start the remote tool when the SMSM service isn't running.
162+
- The service does not gracefully shut down the Minecraft server if Windows is shutting down.
163+
- Recommended workaround: Stop the server via the remote tool, or stop the service via `services.msc` before shutting down or restarting Windows.

SMSMRemoteTool/SMSMRemoteTool.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public static void Main(string[] args)
3939
}
4040
PipeRW.WriteLine(UserInput);
4141
}
42+
Stop();
4243
}
4344

4445
public static void Stop()

SMSMRemoteTool/SMSMRemoteTool.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<TargetFramework>net6.0</TargetFramework>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
8+
<AssemblyVersion>1.1.0.0</AssemblyVersion>
89
</PropertyGroup>
910

1011
</Project>

SMSMService/SMSMService.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<UserSecretsId>dotnet-WorkerSvc-AF94159C-698F-409B-B8C8-C875CA76A729</UserSecretsId>
8+
<AssemblyVersion>1.1.0.0</AssemblyVersion>
89
</PropertyGroup>
910

1011
<ItemGroup>

SMSMService/Server.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ public static bool StartServer()
2929
ServerProc.OutputDataReceived += ServerOutputHandler;
3030
ServerProc.ErrorDataReceived += ServerErrorHandler;
3131
ServerProc.Start();
32+
ServerReady = true;
3233
ServerProc.BeginOutputReadLine();
3334
ServerProc.BeginErrorReadLine();
34-
ServerReady = true;
3535
Log.Info($"Server process started as PID {ServerProc.Id}");
3636
return true;
3737
}
@@ -64,6 +64,7 @@ public static void KillServer()
6464

6565
private static void ServerExitHandler(object? sender, EventArgs evt)
6666
{
67+
ServerReady = false;
6768
Log.Info("Server process exited.");
6869
if (ServerProc != null && ServerProc.HasExited) { ServerProc = null; }
6970
}

SMSMService/Start.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@ public static async Task Main(string[] args)
88
SMSM.ConfigFile = args[0];
99

1010
string LogDate = DateTime.Now.ToString("yyyy-MM-dd\\_HH-mm-ss");
11-
try { Log.LogFile = new StreamWriter(File.Create($"C:\\Games\\Minecraft\\LTS\\SMSMLog-{LogDate}.txt")) { AutoFlush = true }; }
11+
try
12+
{
13+
string ExePath = AppDomain.CurrentDomain.BaseDirectory ?? "";
14+
string LogFileName = $"SMSMLog-{Environment.UserName}-{LogDate}.txt";
15+
string LogFilePath = Path.Combine(ExePath, LogFileName);
16+
Log.Info($"Attempting to log to \"{LogFilePath}\"");
17+
Log.LogFile = new StreamWriter(File.Create(LogFilePath)) { AutoFlush = true };
18+
}
1219
catch (Exception Exc)
1320
{
1421
Log.Error("Could not create log file.");

0 commit comments

Comments
 (0)