I’m trying to run a “server” version of my game in headless mode on linux. I make the build (and mark the “headless” box) and am able to run the app. However, I need for the app to be able to detect that it is running on the server. My first thought was to have a function like:
bool IsServer()
{
string[] args = System.Environment.GetCommandLineArgs();
return Array.IndexOf(args, "--server") > 0;
}
And then running the app like “./appname_x86_64 -nographics -batchmode -logfile log.txt --server”. The app launches, but it doesn’t seem to run as a server (but I’m not sure how to tell if it got the correct result from the IsServer()
call.
So two questions, firstly is this a good way to detect if it is running on the server? Secondly, is there a way for me to output something to log.txt
so I can debug a little? Something like Debug.Log()
but that prints out in log.txt
so I can tell how my code ran / what points it got to.