I want to build a DedicatedServer on Linux! So, make a note of what I tried variously
First, let's check that it works on the editor [Selected Viewport] x [Standalone Game] x [Play Offline] x [Play As Client] x [Number of Players] I will check the operation of each of these combinations, so it's quite Taihen. ..
If you start it with PIE, you can trace all server and client processes. This is convenient, but if you follow a function that is called CLI1, CLI2, SERV multiple times (BeginPlay, etc.), your head will get very tired (!). Describes how to start processes individually
RunServer.bat
:: [UE4DIR], [ProjectName]Replace with your own environment
set EDITOR=[UE4DIR]\Engine\Binaries\Win64\UE4Editor.exe
set GAME_UPROJECT=%~dp0%\[ProjectName].uproject
::Optional launch map
::The default is the project settings[Server Default Map]Is used
set MAP_NAME=
::Start the server from the editor
start %EDITOR% %GAME_UPROJECT% %MAP_NAME% -server -log
exit
RunClient.bat
set EDITOR=[UE4DIR]\Engine\Binaries\Win64\UE4Editor.exe
set GAME_UPROJECT=%~dp0%\[ProjectName].uproject
start %EDITOR% %GAME_UPROJECT% -game -log -windowed -ResX=1024 -ResY=576
exit
Next, I will describe binary creation
The target file does not exist in the template, so add it
[ProjectDir]/Source/[ProjectName]Server.Target.cs
using UnrealBuildTool;
using System.Collections.Generic;
public class [ProjectName]ServerTarget : TargetRules
{
public [ProjectName]ServerTarget(TargetInfo Target) : base(Target)
{
Type = TargetType.Server;
DefaultBuildSettings = BuildSettingsVersion.V2;
ExtraModuleNames.Add("[ProjectModuleName]");
}
}
Please add by referring to [ProjectName] .Target.cs in the same directory. After adding the file, update the VS file from the uproject menu Make sure you have more targets (VSCode image)
There are many tutorials on ProjectLauncher when you google, It is not necessary to start the editor, so it is recommended to execute it from a batch file.
BuildServer.bat
set ENGINE_ROOT=[UE4DIR]\Engine
set GAME_UPROJECT=%~dp0%\[ProjectName].uproject
::If one line is long^Line break with
::If you enter start, the window will remain at the end
start %ENGINE_ROOT%\Build\BatchFiles\RunUAT ^
BuildCookRun -project=%GAME_UPROJECT% ^
-nop4 -build -cook -compressed -stage ^
-noclient -server -serverplatform=Win64 -serverconfig=Development ^
-pak -utf8output
When BUILD SUCCESSFUL is displayed, it is complete. Packages will be generated under [ProjectDir] \ Saved \ StagedBuilds \ Windows Server Open the folder in explorer and type cmd to open a command prompt on the fly (I didn't know) Run the exe with the -log argument to start the server You can connect to the server by launching PIE, pressing the @ key, and typing [open 127.0.0.1].
Read Linux Cross-Compiling first. Did you read it? What should I do··· Should I build in a Linux environment in the first place? You thought so! !! !! When I tried to create a P4 environment and submitted and updated UE4DIR, it looked like this, so I was scared and stopped. When you hit Setup, it's about 120GB, so ... the volume isn't enough in the first place ... Building Unreal Engine Game Client and Dedicated Server on Linux There are people who are doing it, but what kind of operation is it?
That's why build on Windows-> transfer only executable files
Clicking link does not start the installation, but Right-click-> Open new window to install Run Generate Visual Studio project files again and Linux should be added to the target (I don't have confidence in the details around here ...)
Change -serverplatform in BuildServer.bat to Linux and build & cook Success if packaged in \ Saved \ StagedBuilds \ LinuxServer
It's not the main subject so only the main points
Launch t3.micro (cheaper than t2, next generation, but not free)
In t3.nano, the server cannot be started because there is not enough memory </ font> (described later)
The default volume of 8GiB wasn't enough, so I increased it to 16GiB (be careful about weight loss because it's too annoying!) Reference: EC2 Volume (EBS) Capacity Expansion Method Verification (Amazon Linux)
I want to start it only when I use it, so it's easier to fix it with Elastic IP
UE4 communication uses UDP: 7777, so let's open it
Transferred with WinSCP \ Saved \ StagedBuilds \ LinuxServer \ [ProjectName] \ Binaries \ Linux \ [ProjectName] Server.debug has a large capacity, so decide whether to transfer it according to your purpose. It may be necessary for development because it follows stack traces with gdb
$ ./[ProjectName]Server.sh -log
I will try to execute the command for the time being,
./[ProjectName]Server.sh: line 5: 2950 Segmentation fault
"$UE4_PROJECT_ROOT/[ProjectName]/Binaries/Linux/[ProjectName]Server" [ProjectName] "$@"
w
$ gdb [ProjectName]Server
GNU gdb (GDB) Red Hat Enterprise Linux 8.0.1-30.amzn2.0.3
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from [ProjectName]Server...Reading symbols from /var/www/[ProjectName]/Binaries/Linux/[ProjectName]Server.debug...done.
done.
(gdb) run -log
Starting program: /var/www/[ProjectName]/Binaries/Linux/[ProjectName]Server -log
fork: Cannot allocate memory.
(gdb)
Cannnnnnnnnot allocate memory!!! So I changed from t3nano to t3micro and was able to start up safely Confirm that you can connect with [open ###. ###. ###. ### (GlobalIP)]
//Grant execute permission to start with nohup
$ chmod +x SlothServer.sh
//standard/Change the error output as appropriate
//MapName is optional (if not specified)[Server Default Map])
$ nohup ./SlothServer.sh [MapName] > nohup.out 2> nohup.err &
$ pkill SlothServer
How To Set Up Dedicated Servers for Windows and Linux For Your UE4 Game (using Windows) Legacy/Dedicated Server Guide (Windows & Linux)
Recommended Posts