NEOTOKYO°

NEOTOKYO°

Not enough ratings
WINE Neotokyo Server Guide
By [*RO*]Phorce_Phed
How to run a Neotokyo server under Linux using WINE.
   
Award
Favorite
Favorited
Unfavorite
Requirements & Recommendations
The Windows version of the Source Dedicated Server (SRCDS) can be run with a fairly limited Linux install: Although the SRCDS console runs in X, a complete X environment is not required and all administration can be accomplished without a GUI (from your native console interface).

Items below tagged with the <(d)> should ideally be downloaded from your Linux distribution's repositories using whatever package manager you are comfortable with -- NOT directly from the links I am providing.

Requirements
  • SteamCMD (Linux)
  • WINE[www.winehq.org] 1.4 or newer <(d)>
  • Xvfb[en.wikipedia.org] <(d)>
The last item is not required if you already have a complete X environment that you intend to use (by way of VNC or whatever).

Recommendations
  • Vrcon[files.repeatoffender.net]
  • rcon[github.com] (preferred) or rubycon[github.com] (deprecated)
  • SRCDS Guardian[pastebin.com] - Remove all instances of the "&" (ampersand) character from this file before using.
  • Tofrodos[www.thefreecountry.com] <(d)>
  • x11vnc[github.com] <(d)> or the VNC server of your choice.
  • Fluxbox[fluxbox.org] <(d)> or whatever window manager[en.wikipedia.org] you prefer, but lighter is better.
Install Neotokyo and SRCDS
  1. Download and install SteamCMD for Linux using the Valve wiki page linked above.

  2. Decide where you want to install your Neotokyo server and create that directory. For the purposes of this guide, the Neotokyo server install directory will be: /your/install/directory/here

  3. Start SteamCMD and enter the following:
    @sSteamCmdForcePlatformType windows force_install_dir /your/install/directory/here login anonymous app_update 313600 validate quit
Configure, Start and Stop
  1. Edit the server.cfg in /your/install/directory/here/NeotokyoSource/cfg/

  2. Make sure you have 32-bit WINE installed (it should complain and tell you exactly how to do this if you don't) then generate a WINE bottle (only needs to be run once):
    export WINEARCH="win32" wine winecfg
    If running without a GUI you will see "err:ole" and "err:winediag" errors, but these can be disregarded as long as you also see a line like this:
    wine: configuration in '/home/username/.wine' has been updated.

  3. Use your server's actual IP in place of 10.10.10.10 below and change whatever other srcds.exe flags you want:
    cd /your/install/directory/here/ Xvfb :1 -screen 0 800x600x16 & export DISPLAY=":1.0" wine start srcds.exe -console -game NeotokyoSource +ip 10.10.10.10 -port 27015 +maxplayers 32 +exec server.cfg +map nt_dawn_ctg
    Note that some things in the above block of commands are required and not including them will prevent the server from starting:
    • Xvfb needs 16-bit color (the "x16" part)
    • wine needs correct syntax (the "start" part)

  4. Give it a few seconds and check your Steam server browser, the server logs under NeotokyoSource/logs or look for srcds.exe in process list on your server.

  5. To shut it down:
    pkill srcds.exe pkill Xvfb
Enhancements
VNC
Because the Windows CUI version of SRCDS is not fully compatible with WINE (does not work with wineconsole[www.winehq.org]) it will still be running in X rather than your native console. Should you be running Xvfb and need to reach the actual SRCDS console (rather than using rcon) for troubleshooting or other purposes, VNC[en.wikipedia.org] is one way of doing that. For security, run the VNC server on localhost and connect to it via an SSH tunnel.

Starting VNC:
x11vnc -quiet -display :1 -bg -nopw -listen localhost -forever -autoport 5900 &

SSH tunnel (run on your local machine):
ssh -fNL localhost:50900:localhost:5900 your_shell_username@example.com
This can also be accomplished with PuTTY and other SSH clients.

Then connect to localhost:50900 with your VNC client.

rcon / rubycon
The rcon utility can be used to access your server's rcon directly from your native shell (bash, etc.) allowing you to simplify or automate virtually any server task. Here's a script that uses the rcon utility to monitor SRCDS for lock-ups (something SRCDS Guardian doesn't do):

#!/bin/bash # Server name in square brackets from ~/.rconrc sn=servername # SRCDS install directory prefix=/your/install/directory/here # The user running SRCDS uzr=username check_errorstatus () { errorstatus=$(rcon -s $sn stats &> /dev/null ; echo $?) } while : do sleep 5m check_errorstatus if []; then sleep 1m check_errorstatus if []; then echo -e "\n`date` -- Server hang detected! Killing SRCDS now...\n" 1>>$prefix/ntwatch.log pkill -9 -u $uzr srcds.exe fi fi done

For historical purposes, here is the same script using the deprecated and unmaintained rubycon utility instead of rcon:

#!/bin/bash # See ~/.config/rubycon/rubycon.yml sn=servername # SRCDS install directory prefix=/your/install/directory/here # The user running SRCDS uzr=username check_errorstatus () { errorstatus=$(rubycon list $sn &> /dev/null ; echo $?) } while : do sleep 5m check_errorstatus if []; then sleep 1m check_errorstatus if []; then echo -e "\n`date` -- Server hang detected! Killing SRCDS now...\n" 1>>$prefix/ntwatch.log pkill -9 -u $uzr srcds.exe fi fi done

The above scripts run in an infinite loop, so should be started in the background.

SRCDS Guardian
A batch script long used by Windows SRCDS admins to start SRCDS and restart it when it crashes.

Command:
wine start cmd /k SRCDS\ Guardian\ 3.bat
See warning in the first section of this guide.

An interesting fact about the WINE v1.4 cmd implementation: Anything non-Windows gets passed back to the shell. This is useful if you want a shell script to fire every time SRCDS is (re)started, as you can simply edit SRCDS Guardian like so:

::Start the actual server /usr/local/bin/example.sh start /wait %runcmd%

Newer versions of WINE have eliminated this feature, but you can still accomplish the same thing by using the start command with the /unix flag:

::Start the actual server start /unix /usr/local/bin/example.sh start /wait %runcmd%

SourceMod
You will (of course) need to run SourceMod for Windows, which means that if you wish to compile plugins locally it will need to be done under WINE. Happily, WINE has better support for the Pawn compiler than it does for SRCDS so you can use wineconsole for this. Create a batch file in your SourceMod scripting directory named go.bat:

@ECHO OFF spcomp.exe %1 pause

Then create a shell script named go.sh and make it executable:

#!/bin/bash wineconsole --backend=curses go.bat $1

To compile a plugin named example.sp: ./go.sh example.sp
Troubleshooting
If you are experiencing poor performance (50% CPU use with an empty server) try this older version of SRCDS: https://files.repeatoffender.net/details.php?file=47

For other issues, use these steps in order:

  1. Google any errors you get.

  2. See the Troubleshooting section of Rain's guide and follow the instructions there:
    http://steamcommunity.com/sharedfiles/filedetails/?id=281433778
< >
12 Comments
daxxy Aug 5, 2014 @ 12:20pm 
I just switched to a Windows VM on my Linux server (1 core, 2GB RAM, Win7 64-bit on E3-1220, Linux 3.13 running KVM) for stability and saw the same CPU usage patterns with old srcds vs current srcds as on Wine, so it seems to be a problem with srcds itself, not Wine.
[*RO*]Phorce_Phed  [author] Jul 12, 2014 @ 10:19pm 
VPS: A single "HT CPU core (Nehalem or better)" with a 6 slot instance (no SourceMod): http://imgur.com/KqazH6y.png

Production: Opteron 1222 with a 32 slot instance (SM 1.5 with 50 plugins): http://imgur.com/S6eCIDj.png

Both of the above images show -console SRCDS processes that were freshly started, slots empty, running SourceTV. I am using the older SRCDS files (previously linked in the guide) on the production server, while the VPS has the latest from SteamCMD.

Production CPU utilization nearly tops out with two fully utilized 24-slot instances.
daxxy Jul 12, 2014 @ 9:16pm 
By the way, what kind of CPU usage pattern are you getting? Because srcds and wineserver are hogging all my cores, adding 0.5-1.0 to my overall load average, regardless of whether the game server is actually doing anything. Meaning same high CPU usage when the server is full, when it's empty and when it's not even really running at all (as in, just starting the executable in graphical mode, before clicking the Start Server button). And that's on a Xeon E3-1220, so it's definitely not too weak for one srcds with low usage otherwise.
[*RO*]Phorce_Phed  [author] Jul 12, 2014 @ 8:49pm 
Correct, start is critical. I spent a lot of time figuring that out when it became necessary last year, because it's not just due to changes in WINE but also changes in SRCDS:

http://forum.radi-8.com/viewtopic.php?f=13&t=1194&start=20#p21990
daxxy Jul 12, 2014 @ 7:22pm 
Alright, I got it now. Running "start" (as in, "wine start srcds.exe" rather than just "wine srcds.exe") seems to be required - but only for the console version. I still have absolutely no idea why.
[*RO*]Phorce_Phed  [author] Jul 12, 2014 @ 12:06pm 
DrDaxxy: I just spun up an NFOservers VPS with Debian Wheezy and ate my own dog food here, following each step in the guide exactly. It worked with the stock SteamCMD files and I had a simple Neotokyo server (with SRCDS console interface) up and running in just over an hour (including file transfer times). Packages installed:

wine
ntp
xvfb
screen
x11vnc

The only thing in the guide that didn't work as expected was that the screen session did not stay active, but srcds.exe did. It is accessible with VNC (and the Steam server browser) as I type.

I think the issue you're seeing is related to your environment somehow. Maybe WINE version, kernel version or something else.
daxxy Jul 12, 2014 @ 7:31am 
Back when Garry's Mod had no Linux server, I've also successfully run console SrcDS in Wine. Current Windows SrcDS 2006 instantly closes when run in console mode in Wine for me though. Yes, on an X server, and I've tried the older version you posted too.

Using VNC as suggested in the guide to remotely display X applications, rather than X2Go, is definitely the better way though. I've discovered that for some reason, fps significantly go down in a suspended X2Go session. Without any effect on process priority/nice value or CPU usage, strangely enough.
[*RO*]Phorce_Phed  [author] Jul 11, 2014 @ 7:26am 
The console version of SRCDS does work (I'm running it and have been for years) but it will not run in your native console, only in X.

I've updated the guide to include the new install instructions and some additional management info.
daxxy Jul 8, 2014 @ 7:58pm 
As I've mentioned in the other thread, running the graphical version of SrcDS seems to work where the console version doesn't - though you'll need an actual X server. Currently running a graphical one over X2Go (which allows you to run a desktop environment on your server and have it displayed on your client, much like RDP).
This probably doesn't play so well with watch dogs though.
coLdduff Jul 8, 2014 @ 12:22pm 
I was having an issue where wine was using 100% of 1 CPU core permanently.

It looks like I have figured out my issue. I was running srcds from the location where I store all my servers at in /home/name/steam/games/neotokyo. If I run srcds.exe from /home/name/.wine/drive_c/srcds/neotokyo I do not have the 100% cpu usage issue.

Since I didn't want to move my neotokyo folder, I just created a symlink to get the job done and it seems to work just fine.


mkdir /home/name/.wine/drive_c/srcds/neotokyo

ln -s /home/name/steam/games/neotokyo /home/name/.wine/drive_c/srcds/neotokyo

Maybe this was obvious to some but I have never used wine before. Thanks for the wine guide Phorce.