question

Brent Batas (Lisk) avatar image
Brent Batas (Lisk) asked

How to check if the server exe is, in fact, running without errors?

My server currently writes text logs to the log_file_path and various other logs to the output_files_directory_path folder.

However, after terminating the server instance, the logs are blank and the output files are empty.

I suspect that the server exe itself may not be running or may have errored.

Is there a way to check if my server exe is, in fact, running without errors?

Custom Game Servers
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

Any log file written to the log_file_path generated by the Game Wrangler when we start your server is captured when the executable stops running on the server, but only if the server host is still running. If you use the Terminate option on the server host tab (Servers->Servers), that kills the host itself, preventing us from collecting the log files. If you believe your server is writing to the right location and you're not using the server host terminate option, please let us know the Title ID you're testing and we can have a look at the running server to confirm whether it is writing a log file to the right location.

23 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Brent Batas (Lisk) avatar image Brent Batas (Lisk) commented ·

I've been terminating the server instances via Servers->Active Games->Terminate Server Instances as you mentioned in another comment.

I believe my server is writing to the right location (based on my local tests only though).

My title ID is 9092.

0 Likes 0 ·
brendan avatar image brendan Brent Batas (Lisk) commented ·

Thanks - that let me hop on the server and have a look. The issue is that you're not writing the log to the file specified by log_file_path. You're creating a sub-folder in the folder where the log file should be written, and then writing multiple log files there. The game wrangler is looking for the specific log file specified in log_file_path. For output files, we don't specify a filename on the path, so you can write whatever you want to there, but they do need to be in the specified folder, not sub-folders.

0 Likes 0 ·
Brent Batas (Lisk) avatar image Brent Batas (Lisk) brendan commented ·

Thanks for looking into this. I must be misunderstanding what I am supposed to do.

In my local tests, I run the command like follows:

E:\dev\AEServer\bin\AEServer.exe -output_files_directory_path="E:\dev\AEServer\bin\the_output_files_path" -log_file_path="E:\dev\AEServer\bin\the_log_file_path.txt"

This correctly writes custom HTML logs to the output_files_directory_path and uses a trace listener and Trace.WriteLine to write to the path specified by log_file_path.

What am I doing wrong?

0 Likes 0 ·
Show more comments
Brent Batas (Lisk) avatar image Brent Batas (Lisk) commented ·

Hi @Brendan to continue the conversation: I'm not sure how else I can re-check it other than what I've done so far.

I'm creating a TextWriterTraceListener with the path set to the value of log_file_path. I then add that listener to Trace.Listeners and set Trace.AutoFlush to true. It works with the command arguments in my previous post.

0 Likes 0 ·
brendan avatar image brendan Brent Batas (Lisk) commented ·

Since you had a server running, I went ahead and started a game with your user ABBE25EA7CF4CDDB. Here's what I'm seeing:

The Lobby ID is 6925754288335123627. The log_file_path we send to your game in the command line always uses the Lobby ID as the log filename (so, 6925754288335123627.log). In your logs folder, I'm seeing that your game server is writing to a log file named "20-34-58 PM.txt" - which is the time I started the session.

I also had a look inside the log file, and your server is failing to start as it's trying to load a "settings.cnf" from the wrong directory - the settings file is in the same sub-folder with the executable on the server, and it's trying to read it from one directory up.

Last item - I had a look in the settings file itself, and it specifies a listener port of 9000. That's not going to work, as we automatically generate a unique listener port for each instance of the game running on the server host, starting at 9000.

Since the build is clearly not working as-is, I've shut down that server instance for now.

1 Like 1 ·
Brent Batas (Lisk) avatar image Brent Batas (Lisk) brendan commented ·

This is helpful, Brendan, thanks!

Regarding logs - I think I am misunderstanding how the log_file_path is passed in. I'm assuming it is passed in the format of "-log_file_path=absolutePath" but it sounds like my game is not interpreting it properly. It could be a cascading error based on being unable to find the settings.cnf

Regarding settings.cnf - That's odd that it is trying to read from one directory up, since it reads from the same directory on my local version. I'll follow up with my server programmer.

I should be able to debug those two things and then try again.

Question: In the future -- is there a more automated way that I can diagnose this type of problem on the server? I wouldn't have known what was going wrong without you telling me.

0 Likes 0 ·
Show more comments
Brent Batas (Lisk) avatar image Brent Batas (Lisk) commented ·

Hi again @Brendan I made several changes, namely bootstrapping my exe so that I am able to accept all the proper arguments from the server.

Everything runs fine on my local machine. I tested running my new exe from a subfolder and it works.

I uploaded the latest zip to the server (with the exe at the root), but still: no logs, no output, no connection.

Would you mind looking into this again? Thank you!

0 Likes 0 ·
brendan avatar image brendan Brent Batas (Lisk) commented ·

Sorry, but your server still isn't creating the log file using the info specified. I should see a log file with the LobbyId (sometimes called the GameId) as the name and log as the extension - that's what gets passed in as the filename in log_file_path. Can you try starting your local server test with something like (assuming Z is your test drive) "Z:\gameserver\logs\1234567890.log"? That would closely approximate what we send as the log_file_path currently.

0 Likes 0 ·
Brent Batas (Lisk) avatar image Brent Batas (Lisk) brendan commented ·

I just ran the test with setting log_file_path to "E:\gameserver\logs\1234567890.log" and it worked as expected. It produced a new log called 1234567890.log and wrote a bunch of log stuff from my server.

0 Likes 0 ·
Show more comments
Brent Batas (Lisk) avatar image Brent Batas (Lisk) commented ·

@Brendan See the following code:

// Text Tracer
Console.WriteLine("#TRACE flag enabled. Writing error+ logs to: " + path);
twtl = new TextWriterTraceListener(path) { Name = "texttrace" };
Trace.Listeners.Add(twtl);
Trace.AutoFlush = true;

I am calling my exe with the following shortcut:

E:\dev\AEServer\bin\Bootstrapper\AEServerBootstrapper.exe -commands="validate 2" -server_host_port=9000 -log_file_path="E:\gameserver\logs\1234567890.log"

Upon reviewing my server logs, I see the following output (screenshotted, just to be sure there is no typo)

Also useful may be the spec for TextWriterTraceListener

0 Likes 0 ·
brendan avatar image brendan Brent Batas (Lisk) commented ·

Yes, I'm familiar with TextWriterTraceListener, though I'll admit I don't use it for logging. Your code snippet doesn't show how you're creating the Stream that you pass into the Listener, though. Where are you creating the file for the Stream?

0 Likes 0 ·
Brent Batas (Lisk) avatar image Brent Batas (Lisk) brendan commented ·

I just call Trace.WriteLine("hello world") elsewhere. I also have my log methods use [Conditional("TRACE")] and [Conditional("DEBUG")] tags, since I want to be able to compile without those flags later if I want to.

In terms of how the file is created, I think it is just auto-created from the twtl.

0 Likes 0 ·
Show more comments
Brent Batas (Lisk) avatar image Brent Batas (Lisk) commented ·

@Brendan wow, great find! That would explain it. Do you know if there is a way to emulate running the server as a NETWORK_SERVICE user on my local machine?

I want to be able to repro this on my end, especially if there are other unforeseen circumstances of running as NETWORK_SERVICE.

0 Likes 0 ·
brendan avatar image brendan Brent Batas (Lisk) commented ·

Sure - there's a pretty good guide to the ins and outs of this here: http://geek.hubkey.com/2008/02/impersonating-built-in-service-account.html.

1 Like 1 ·
Brent Batas (Lisk) avatar image Brent Batas (Lisk) brendan commented ·

Thanks - I was able to reproduce a System.UnauthorizedAccessException by running as a network user.

Would StreamWriter work as an alternative? If not, what class would you recommend using for writing logs?

I'm just trying to get a sense of what's the best practice.

0 Likes 0 ·
Show more comments
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.