Search Unity

Standalone headless server - console window?

Discussion in 'Multiplayer' started by PhobicGunner, Oct 22, 2013.

  1. PhobicGunner

    PhobicGunner

    Joined:
    Jun 28, 2011
    Posts:
    1,813
    I'm experimenting with some features of Unity for multiplayer, one of these being the ability to run games in headless mode with the -batchmode command.
    I expected that this would provide me with a console window with just the debug output of my game being displayed.
    Instead, what I get is a game that runs completely invisible in the background. No windows, no terminals, not even a system tray icon. In fact, absolutely zero feedback that anything useful happened, the only reason I know it's running is by checking process explorer.
    For dedicated servers like an MMO, this is OK (but not ideal).
    For standalone servers such as a game like Minecraft, this would be incredibly confusing for players. They might not even realize the server has started, attempting to start the server several times (leading to many server instances in the background).
    Is there any way to display a terminal window instead of just silently running like this?
     
  2. Christian-Tucker

    Christian-Tucker

    Joined:
    Aug 18, 2013
    Posts:
    376
    You could always... you know, debug it.

    or write your own stand-alone server. (Recommended)
     
  3. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    Writing to the console is ok during development but sooner or later it will take away performance you better use for players.
    Also you will want to change logging levels by a config, instead of recompiling things so I highly recommended to use some logging tool like log4net.
     
  4. PhobicGunner

    PhobicGunner

    Joined:
    Jun 28, 2011
    Posts:
    1,813
    How would debugging help me? I'm talking about end users being able to start up a standalone server which, ideally, would have some kind of console window or at least some kind of indication that it's running.
    Additionally, writing a custom server is not an option if I want the server to have even the tiniest bit of authority over gameplay in, say, a first person shooter, unless I feel like rewriting Unity as a console application.

    I can always reduce the amount of information being logged, but first what I want is just to display a console window, otherwise my server has zero indication that it's even running until you check task manager. The console window isn't so much for debugging as it is for just letting people know the server is up and running (and serving as a way to close the server without having to manually kill the process from task manager)
     
  5. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    I don't know how you can open a console for it. Maybe this depends on the compile options when building the player. Not sure if you can modify this.
    As alternative, you could write a separate application which starts, monitors and stops the Unity process. We do this with Photon Control. It's a independent app that checks processes and detects if our server is running, etc.
     
  6. rsr137

    rsr137

    Joined:
    Oct 7, 2014
    Posts:
    6
    It seems the easiest way is write a custom launcher for server in c#. something that shows console, lauches your standalone headless unity server than waits console outputs or simular cross process messages from it and display in laucher console. May be confusing but could be accomplished with 10-15 lines of code.
     
    bluetea_nick likes this.