I’m running Windows Server 2008 and trying to setup Unity game servers to run as Services. I’ve found a couple of threads dealing with this (here and last post in this thread) but so far no real solution has been found.
All the games are running with -batchmode and -nographics switches but they still show the Unity system tray icon - which is a problem as in Windows 2008, all services run in Session 0 and can never do anything to the display - this includes showing windows, messages AND adding system tray icons. When trying to run a game, it crashes at start and the output log shows Failed to add notify icon..
So, what we need is: Find a way in the code to prevent Unity from showing a system tray notification icon.
Running the games as services is critical, we don’t want to have to login and manually start them after a reboot, after a power failure or a Windows update installed and rebooted.
Using the Auto-logon feature and putting the games in the startup folder is not an option - we are talking about a production environment and using Auto-logon is definitely not professional (plus what happens when the password expires? Or when someone logs in with Remote Desktop, which could log off the automatic session?)
I’m really curious to see how other people are running game servers, does everybody use a standard login session and that’s it? Nobody else finds the need to use Services to make sure game uptimes are the best possible?
I can’t help with your actual question of running Unity as a service, and as a caveat I don’t know much about Unity’s built-in networking, but I really have to wonder why you would need it in the first place. If you want to run a game server, you don’t need that game server to run Unity at all, and in fact it seems somewhat counterproductive to try that since you’d have unnecessary overhead for the graphics, UI, etc. parts of Unity.
You might want to either look into off-the-shelf solutions like SmartFoxServer ( http://smartfoxserver.com , it’s what we use ) or simply code your own sockets-based server in Java or similar, I’ve seen both approaches work well.
I’m just a sysadmin, not the one coding the actual game servers. I also think that writing a standalone server would work better but I’m not taking any decisions - it seems the dev team decided to code the networking side using Unity as well…
From that error on the other linked thread, simply install a video card that supports graphics regardless of its use, there are checks when Unity starts up to see if the minimum graphics are supported, this will cost you something like $20 at a local computer store. Try that first.
Hi zumwalt, I don’t think you’ve really read my post. The problem is not about needing a video card, it’s about the fact that Windows 7 and 2008 services CANNOT add icons to the system tray, services are not allowed to touch the display. Our problem is that we cannot make Unity games manageable by using Windows Services, which is the only real way to automate anything on Windows in a production environment.
Also, we are using Dell servers, not PCs. There are no slots for video cards, those are enterprises 1U servers. But that’s beside the point.
Unity would need certain changes to make this work and I don’t think it’s possible at the moment. By the way Windows 2008 is not supported but the fact that issue occures on Windows Vista and 7 makes it likely to be fixed (especially after you submitted bug report :).
Thats a theory I won’t sign at all as you can always make a manager that handles it and thats started up as the machine is started (the same naturally could be done with the unity instances too)
Cause you will normally need more than 1 instance anyway, a variable one potentially, if you do a real game so you want a “cluster node” how I tend to call it, a main program that manages the running instances on this machine, fires up and shuts down those not needed etc (-> “load balancing”) and especially and most importantly ensures that the log files are copied on crashes and alike.
Even if you got rid of the icon, there are still things in unity that would prevent it from running as service and I don’t forsee that this is going to change as the stuff is meant for game development with kind of a primary intend of player hosted games, its not meant for business development and services as its not remotely in the lightweight range.
Also the GPU part can be skipped if you start with -batchmode.
We have written a manager that takes care of starting game servers as requested by game lobbies, does the load balancing between our many servers and kill the games when all players are gone, etc. That works fine. But if we set that manager to run as a service, then it cannot actually starts any games compiled with Unity - because of everything that affects the display.
You mention that there might be other things that would prevent games to run as services. Like what? From the debug logs, it seems the main problem is indeed when trying to add a display icon. And the display icon is only added when the -batchmode switch is used.
Our current hack solution is this:
We created a special Windows account under which our manager will run. We set that account to Auto-login. I added a Scheduled Task to launch our game manager when that account logs in. So far it seems to work, which is good. But it’s nowhere as clean and as professional as having everything run as Services.
Unity is not meant for business development, that made me laugh. Tell that to our entire Unity department.
Amending my last post, using Scheduled Tasks don’t work either, we get the same error:
Failed to add notify icon: The operation completed successfully.
Failed to add notify icon.
Failed to initialize batch mode window.
Failed to destroy batch mode menu: Invalid menu handle.
Failed to create batch mode window: The operation completed successfully.
I would also like to launch my unity server on windows server 2008.
Sorry if it is a stupid question : is it possible to launch the server manually by command line on the server ? (not using services then, I don’t need, because it’s a student project)
Of course you can do that, just run your executable with the -batchmode switch.
My problem is, using -batchmode created a notify icon in the system tray and that can’t happen in Windows Vista, 7 and 2008 as services aren’t allowed to access the display.
By the way, I have opened a bug with Unity about that back in December, it’s still flagged as “Open” with no comments.
A way to address this is using the schedules to start it on startup that way, problem is that you can’t make it autorestarting in case of a crash for example (so you would use the schedule to start a handling application that starts and restarts it in case of failure)
Yes, as a temporary solution, we are using an autologon user that starts at login the program we wrote that starts/stops/restarts our Unity games. But we currently have 4 servers and if we have to modify or restart the wrapper program, that means manually login on each one. If this was a service, it could all be done remotely and automatically.
This is management hell and a seriously ridiculous way to deal with production servers.
And really, ALL this needs is a way to prevent Unity from adding a system tray icon. The -batchmode switch adds the icon but the -nographic switch could simply prevent it from being added.
Also, since every time a Unity game is started, it adds an icon but it’s not removed automatically when the app stops. Which leads to things like this: