> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# LocalMultiplayerAgent를 사용하여 프로세스 기반 게임 서버 디버깅

> 기존 서버를 래핑하고 프로세스(비컨테이너) 모드에서 LocalMultiplayerAgent 아래에서 실행하여 PlayFab 멀티플레이어 게임 서버를 로컬로 디버깅합니다.

# 프로세스 모드에서 LocalMultiplayerAgent를 사용해 게임 서버를 실행하는 방법

이 튜토리얼에서는 다음을 설명합니다:

* Wrapper 샘플을 사용해 빌드 생성
* MultiplayerSettings.json 구성
* LocalMultiplayerAgent 실행
* 게임 연결 테스트

## 게임 빌드 생성

LocalMultiplayerAgent(LMA)를 사용해 게임 서버를 테스트하려면 게임 빌드를 만들어 아카이브 형식으로 저장해야 합니다.
편의를 위해 지침과 PowerShell 스크립트와 함께 Wrapper 샘플을 제공합니다.

다음으로 이 튜토리얼용 게임 서버를 준비하기 위해 "[wrapper 앱을 사용하여 기존 게임 서버 래핑](https://github.com/PlayFab/MpsSamples/tree/main/wrappingGsdk#wrapping-an-existing-game-server-using-the-wrapper-app)" 단계를 따르세요.

## MultiplayerSettings.json 구성

LMA 툴셋을 압축 해제한 폴더로 이동하여 MultiplayerSettings.json 파일을 엽니다. 이 파일은 MPS의 빌드를 시뮬레이션하는 빌드 구성 모의 파일입니다.

[LMA MultiplayerSettings.json Generator](https://github.com/PlayFab/MpsAgent/tree/main/LocalMultiplayerAgent/SettingsJsonGenerator)를 사용하여 json을 채울 수 있습니다.
Generator는 옵션을 기반으로 json을 생성하는 간단한 웹 페이지입니다. Generator는 LMA를 압축 해제한 폴더 아래에서 찾을 수 있습니다.

다음은 Wrapper 샘플을 프로세스 모드에서 LMA로 실행하기 위한 MultiplayerSettings.json의 예입니다.

```json theme={null}
{
  "RunContainer": false, // Set RunContainer to false if you are running LMA in Process mode.
  "OutputFolder": "C:\\output\\WindowProcess", // Path where config files and logs will be generated from LMA at each run
  "NumHeartBeatsForActivateResponse": 10, // default value
  "NumHeartBeatsForTerminateResponse": 60, // default value
  //the server will run in stand-by mode for 10 heartbeats and stay in active state for 35 heartbeats.
  "TitleId": "59F84", // default value
  "BuildId": "8624d52e-87a1-4a12-b7f6-b92720ef8919", // default value
  "Region": "EastUs", // default value
  "AgentListeningPort": 56001, // default value
  "AssetDetails": [
    {
      "MountPath": "",  // Mount Path is only required for Container mode. leave it as blank.
      "SasTokens": null,
      "LocalFilePath": "D:\\gameassets.zip" // where your game server is located as an archive format.
    }
  ],
  "ProcessStartParameters": {
    "StartGameCommand": "wrapper.exe -g fakegame.exe arg1 arg2" 
    // shell command to run Wrapper. Command will be executed where game asset is extracted.
    // Make sure the StartGameCommand provided above is an example of the Wrapper sample. 
  },
  "PortMappingsList": [
    [
      {
        "NodePort": 56100, // default value
        "GamePort": {
          "Name": "game_port",
           // Port name is already defined in the Wrapper sample. Wrapper will grab the port information using game_port via GSDK while it's running.
          "Protocol": "TCP"
        }
      }
    ]
  ],
}

```

프로세스 모드에서 LMA를 실행하려면 MultiplayerSettings.json의 다음 필드를 올바르게 업데이트해야 합니다.

* `LocalFilePath` - 이전에 만든 게임 서버 자산 zip 파일의 워크스테이션 로컬 전체 경로입니다. 예: D:\MyAmazingGame\asset.zip (JSON 형식을 위해 백슬래시는 이스케이프해야 함).

* `StartGameCommand` - 프로세스에 대한 StartGameCommand 경로는 상대 경로입니다. 작업 디렉터리는 게임 자산이 압축 해제되는 위치가 됩니다.

* `PortMappingsList` - 게임 실행 중 사용할 수 있는 포트입니다.
  * `NodePort`는 워크스테이션에서 열리는 포트입니다.

  * `GamePort.Number`는 프로세스 모드에서 필요하지 않습니다. 게임 서버가 실행 중일 때 GSDK를 통해 포트 번호가 Node Port에 바인딩됩니다. 실제 시나리오에서 MPS는 각 프로세스 기반 게임 세션에 대해 포트를 동적으로 바인딩합니다.

  * `GamePort.Name`을 게임 서버에 정의된 것과 동일한 값으로 설정합니다. 런타임 시 GamePort.Name 키로 GSDK 구성에서 값을 확인할 수 있습니다. Wrapper 샘플을 사용하는 경우 포트 이름이 이미 "game\_port"로 정의되어 있으므로 여기에 동일한 값을 설정해야 합니다.

  * `GamePort.Protocol` - 프로토콜 유형 지정: TCP 또는 UDP

* `OutputFolder` - 출력 및 구성 파일이 생성되는 드라이브 또는 폴더의 경로입니다. 이 경로 아래에 게임 서버가 압축 해제되므로 사용 가능한 공간이 충분한지 확인하세요. 지정하지 않으면 에이전트 폴더가 사용됩니다.

* `AgentListeningPort` - LMA가 게임 서버와 통신하는 포트입니다. 열려 있는 모든 포트가 작동하며 56001이 기본값입니다. 다른 프로세스가 56001에 바인딩되어 있는 경우 이 값을 변경하거나 포트 56001의 다른 프로세스를 종료해야 합니다.

* `ResourceLimits` - 프로세스 모드에서는 필요하지 않습니다.

* `MountPath` - 프로세스 모드에서는 필요하지 않습니다.

* `SessionCookie` (선택 사항) - RequestMultiplayerServer API 호출의 일부로 게임 서버에 전달되는 세션 쿠키입니다. MPS의 실제 시나리오에서 연결이 설정된 후 서버는 SessionCookie에서 해당 리소스를 로드하도록 클라이언트에 알립니다.

## LocalMultiplayerAgent 실행

이제 LocalMultiplayerAgent를 실행할 준비가 되었습니다.

* PowerShell 창에서:\
  LocalMultiplayerAgent.exe가 포함된 LMA 아래 디렉터리로 이동합니다.

* `LocalMultiplayerAgent.exe`를 실행합니다.
  이 시점에서 LMA는 http 리스너를 설정하고 게임 자산의 압축을 해제한 후 별도의 프로세스에서 게임 서버를 시작합니다.

  > 게임 서버를 프로세스로 실행하는 경우 Windows 방화벽이 팝업되어 지정한 NodePort로의 트래픽 허용 여부를 묻는 창이 나타날 수 있습니다. 이를 피하려면 LocalMultiplayerAgent를 관리자 모드에서 실행하거나 방화벽에서 해당 포트를 활성화할 수 있습니다.

LMA는 게임 서버와 통합된 GSDK로부터 하트비트를 기다립니다.
GSDK가 올바르게 통합된 경우 LMA는 다음 순서로 출력을 표시합니다:

1. `CurrentGameState - Initializing`\
   (게임 서버가 GSDK::ReadyForPlayers를 직접 호출하고 GSDK::Start를 호출하지 않는 경우 표시되지 않을 수 있습니다.)
2. `CurrentGameState - StandingBy`
3. `CurrentGameState - Active`
4. `CurrentGameState - Terminating`

게임 서버 상태에 대해 자세히 알아보려면 [PlayFab Multiplayer Server의 게임 서버 수명 주기란 무엇인가요](/services/playfab/multiplayer/servers/multiplayer-game-server-lifecycle)를 참조하세요.

종료 콜백이 올바르게 설정된 경우 상태가 terminating으로 설정된 직후에 게임 서버가 종료됩니다.
PlayFab 플랫폼에서 정상적으로 종료되지 않는 상황을 피하기 위해 게임 서버가 종료되는지 확인하는 것이 중요합니다.

LMA도 게임과 함께 종료되어야 합니다.

## 게임 연결 테스트

LMA가 **CurrentGameState - Active**를 출력하면 IP 주소 127.0.0.1과 게임 서버가 수신 대기 중인 포트 NodePort를 사용하여 게임 서버에 연결할 수 있습니다.

Wrapper 샘플을 사용하는 경우 브라우저에 [http://127.0.0.1:56100/Hello](http://127.0.0.1:56100/Hello) 주소를 입력하여 GET 요청을 테스트할 수 있습니다.
자세한 내용은 Wrapper 샘플을 확인하세요.

또한 MultiplayerSettings.json의 **NumHeartBeatsForActivateResponse** 및 **NumHeartBeatsForTerminateResponse** 값을 업데이트하여 stand-by/active 상태의 지속 시간을 조정할 수도 있습니다.


## Related topics

- [GSDK 프로젝트 테스트 및 디버깅](/ko/services/playfab/multiplayer/servers/server-sdks/unreal-gsdk/third-person-mp-example-project-local-deployment-and-debugging.md)
- [LocalMultiplayerAgent로 컨테이너 게임 서버 디버깅](/ko/services/playfab/multiplayer/servers/LocalMultiplayerAgent/run-container-gameserver.md)
- [LocalMultiplayerAgent 개요](/ko/services/playfab/multiplayer/servers/LocalMultiplayerAgent/local-multiplayer-agent-overview.md)
- [게임 서버 로컬 디버깅 및 PlayFab과의 통합](/ko/services/playfab/multiplayer/servers/locally-debugging-game-servers-and-integration-with-playfab.md)
- [게임 서버를 디버깅하기 위해 직접 연결](/ko/services/playfab/multiplayer/servers/directly-debugging-game-servers.md)
