mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-25 22:17:51 +01:00
Fix service closing pipe after sending command
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.IO.Pipes;
|
||||
using System.Linq;
|
||||
using System.ServiceProcess;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -203,7 +205,17 @@ namespace Tgstation.Server.Host.Service
|
||||
logger.LogDebug("Send command: {command}", command);
|
||||
try
|
||||
{
|
||||
using var streamWriter = new StreamWriter(localPipeServer);
|
||||
var encoding = Encoding.UTF8;
|
||||
using var streamWriter = new StreamWriter(
|
||||
localPipeServer,
|
||||
encoding,
|
||||
PipeCommands
|
||||
.AllCommands
|
||||
.Select(
|
||||
command => encoding.GetByteCount(
|
||||
command + Environment.NewLine))
|
||||
.Max(),
|
||||
true);
|
||||
streamWriter.WriteLine(command);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace Tgstation.Server.Host.Core
|
||||
await serverControl.GracefulShutdown(true);
|
||||
break;
|
||||
case null:
|
||||
logger.LogDebug("Read null from pipe");
|
||||
logger.LogError("Read null from pipe!");
|
||||
return;
|
||||
default:
|
||||
logger?.LogWarning("Unrecognized pipe command: {command}", line);
|
||||
|
||||
Reference in New Issue
Block a user