Beispiel #1
0
 private void HandleUnexpectedExit(object sender, int exitCode)
 {
     State = new StoppedServerState(this);
     State.UpdateStatus();
     _dreamDaemonProcess = null;
     _logger.LogWarning($"Server with id ${Build.Id} unexpectedly stopped. Exit code: ${exitCode}");
 }
Beispiel #2
0
        private ServerStartStopResult StartInternal(ushort port)
        {
            try
            {
                string buildPath   = $"{Build.Path}/{Build.ExecutableName}.dmb";
                var    startParams = new DreamDaemonArguments(buildPath, port);
                var    dreamDaemon = _byond.StartDreamDaemon(startParams);
                _dreamDaemonProcess = dreamDaemon;
                _dreamDaemonProcess.UnexpectedExit += HandleUnexpectedExit;
                Status.Port = port;

                return(new ServerStartStopResult()
                {
                    Message = "Started server.",
                    Id = Build.Id,
                    Port = port
                });
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, $"Error starting server. Id: {Build.Id}");
                return(new ServerStartStopResult()
                {
                    Error = true,
                    ErrorMessage = $"Failed to start server. Exception: \"{ex.Message}\"",
                    Id = Build.Id
                });
            }
        }
Beispiel #3
0
 private ServerStartStopResult StopInternal()
 {
     _dreamDaemonProcess.UnexpectedExit -= HandleUnexpectedExit;
     _dreamDaemonProcess.Kill();
     _dreamDaemonProcess = null;
     return(new ServerStartStopResult {
         Id = Build.Id, Message = "Server stopped."
     });
 }