Initialization of dedicated server?

Where should I add start-up code for a dedicated server properly? E.g. creating a session, changing map, setting the game mode and so on. Would it be correct to do this in the GameInstance’s StartGameInstance method with something like if(GEngine->GetNetMode(GetWorld()) == NM_DedicatedServer) { ... } or what is the recommended way of achieving this?

Have a look at the ShooterGame example. In this game, the code you mention is activated when the user selects a menu option in the main menu. I hope this helps.

That code is dependant on a ULocalPlayer reference passed from the hosting player in order to begin a session using what appears to be a listen server. I am currently trying to figure out how to host a dedicated server with a game session not dependant on a local player hosting it.