Output not flushed if not TTY

Moderator: NADEO

Post Reply
MiniGod
Posts: 27
Joined: 20 Jun 2010, 17:41

Output not flushed if not TTY

Post by MiniGod »

This post is to:
  • give people (advanced users, i guess) a workaround if they have ever encountered this problem.
  • ask why it is like this...
If I don't run the the server in a TTY context, there's no output until the server exits.
Simplest way for you to see it for your self is to run: (notice that there is no output until it exits)

Code: Select all

 ./ManiaPlanetServer /nodaemon | cat 
Since the output is piped, its not in a TTY context.
`cat` is a stupid use case, but you could for instance pipe it to a log service, like loggly.

Why do I want to run it without TTY?
  • pipe - some log services (eg, loggly) have clients you can pipe to to send to them. `./ManiaPlanetServer /nodaemon | loggly-pipe` - or use `awk` to format the lines differently before writing to disk - many possibilities
  • child_process in node.js - running a server as child_process under node.js, and getting a stream of the console could allow for some cool ideas for GSP's.
  • docker.io - magic
There are workarounds, so there is no panic. But I feel like its silly to be needed to run it like this:

Code: Select all

script -qc "./ManiaPlanetServer /nodaemon" /dev/null | cat
With docker, you can add the -t flag, which is not so bad.

To summarize:
What is the reason for not flushing output when not in a TTY context?
And if people has had this issue, and haven't found a workaround. Well... now you have a workaround. (took me a long time to find it)
User avatar
TMarc
Posts: 15255
Joined: 05 Apr 2011, 19:10
Location: Europe
Contact:

Re: Output not flushed if not TTY

Post by TMarc »

nice :thumbsup:

there is also tee and mtee which allows to see both the output and log to a file at the same time.
MiniGod
Posts: 27
Joined: 20 Jun 2010, 17:41

Re: Output not flushed if not TTY

Post by MiniGod »

Good example TMark.

But as of now, you can't really use those tools without a workaround similar to what I described, because there is no output piped from the server until it exits.
User avatar
TMarc
Posts: 15255
Joined: 05 Apr 2011, 19:10
Location: Europe
Contact:

Re: Output not flushed if not TTY

Post by TMarc »

Did you check if the logfiles get written and updated constantly?
Logs/GameLog.txt and Logs/ConsoleLog.txt
MiniGod
Posts: 27
Joined: 20 Jun 2010, 17:41

Re: Output not flushed if not TTY

Post by MiniGod »

The log files are written just fine.
Post Reply

Return to “Dedicated Server”

Who is online

Users browsing this forum: No registered users and 1 guest