Running Hlds.exe As A Service

BakaBakaBakaBaka Join Date: 2003-08-13 Member: 19668Members
<div class="IPBDescription">newbie server admin</div> This is my first time trying to run a dedicated server. Everything installed correctly. My question is, how do you guys run the server? If I log off, the server closes. I'm connecting to the server using remot desktop. If I close my session but stay logged in, the server runs fine. But I don't like leaving my account open like that. Is there a way to run the server as a service or daemon? I'm running it on Windows 2003 with NS 2.0 and hlds.exe v4.1.1.1d. Thanks.

Comments

  • DihardDihard Join Date: 2002-12-02 Member: 10365Members, Constellation
    There's a guide to running SETI@Home as a server <a href='http://www.geocities.com/lwddemon/setiservice/' target='_blank'>here</a> (found with google). The directions should generally be the same but replace everything with hlds instead. I also remember a program that allowed you to set programs to run as services, but I can't remember what it's called...
  • ZdroneZdrone Join Date: 2002-11-02 Member: 3914Members, Constellation
    I think Dihard is thinking of Firedaemon?

    I suggest getting serverdoc. You can start the program in tsclient/tsweb (thats what I assume your using), then just disconnect (dont log off). This will keep it running even if it crashes (it will restart).

    <a href='http://www.serverdoc.com/' target='_blank'>http://www.serverdoc.com/</a>

    If you need any specific help, let me know.
  • MonsieurEvilMonsieurEvil Join Date: 2002-01-22 Member: 4Members, Retired Developer, NS1 Playtester, Contributor
    Do you have access to the Windows NT or 2000 resource kits? You could use the srvany.exe to try and run HLDS as a service. Based on how HLDS is designed to run (a non-terminating process), it should have no problem working that way theoretically. If you do not have access to that, I will post up a similar utility I wrote some time ago (when I get to work).
  • MonsieurEvilMonsieurEvil Join Date: 2002-01-22 Member: 4Members, Retired Developer, NS1 Playtester, Contributor
    edited August 2003
    Finally broke free to make a quick new version of this (couldn't find my old one to save my life, but oh well). This is a compiled script done in WIL 2003G (i.e. 'Winbatch'). It self extracts 2 DLL's to run, so all you need to is to copy the exe somewhere, execute it, and answer its questions. It will then create the service entries to make your EXE run as a service. This will work on XP and 2000 (and technically NT4 too, although it will give you a benign error at the very end which I was frankly too lazy to fix).

    Now - caveats: I have no idea if this will actually work with HLDS. It *will* create a service and you will be able to set startup type to auto and load the service. Depending on how HLDS is written and its exit code though, it may refuse to load properly, may hang, or may not want to run non-interactively. Only testing will tell.

    Some extra notes - the service name is best entered as 8 characters long (and must not be reserved characters like *\&% and so on). The display name can be 256 characters and is what shows up in the service control manager. To uninstall a service, open regedit and delete:

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\(your servicename here)

    then reboot.

    Let me know if you have questions or how this works for you guys. I may not be home tonight as we stamp out te remainder of Blaster.worm in 500 remote bank branches, but I'll try to pop my head back in here...
    ssi.exe 641.4K
  • BakaBakaBakaBaka Join Date: 2003-08-13 Member: 19668Members
    MonsieurEvil thanks for that app. I'll give it try as soon as I get off work. Right now we've been using a shared account and just closing the remote desktop window while leaving the server running. Hopefully this will work. I'm still wondering though. What do other server admins do?
  • MonsieurEvilMonsieurEvil Join Date: 2002-01-22 Member: 4Members, Retired Developer, NS1 Playtester, Contributor
    Did anyone ever try this?
  • DFA_HaploDFA_Haplo Join Date: 2003-01-21 Member: 12537Members
    I tried on Windows XP Pro. I Keep getting an error 1053 somthing about service did not respond in a timely enough fashion.
  • MonsieurEvilMonsieurEvil Join Date: 2002-01-22 Member: 4Members, Retired Developer, NS1 Playtester, Contributor
    edited August 2003
    /me shakes fist at HLDS.exe programmer for not writing his app to load as a service properly...

    Oh well. I have no idea why they wouldn't make that work properly as a service, as all it does is operate basically like a crappy service. Thanks for giving it a try.

    Hmmm... I wonder. Maybe I could write a wrapper for the hlds.exe that had proper service architecture. I'll take a look at this when I get home and have some time to look deeper.
  • DFA_HaploDFA_Haplo Join Date: 2003-01-21 Member: 12537Members
    Oh, not that it should matter too too much but Im running the old HLDS. I havent tried any of the new HLDS' patches or new ones for that matter.
  • ScytheScythe Join Date: 2002-01-25 Member: 46NS1 Playtester, Forum Moderators, Constellation, Reinforced - Silver
    This sounds like a bloodygood idea MonsE!! GOGOGO! You can make it work! We know you can!

    This means I can run a HLDS NS server on my mate's computer at college without him knowing about it. Hehe.

    --Scythe--
  • MonsieurEvilMonsieurEvil Join Date: 2002-01-22 Member: 4Members, Retired Developer, NS1 Playtester, Contributor
    Someday... someday I will actually be home... <!--emo&:D--><img src='http://www.unknownworlds.com/forums/html/emoticons/biggrin.gif' border='0' style='vertical-align:middle' alt='biggrin.gif'><!--endemo-->

    I promise to look into this in the next day or two. Still in the office right now.
  • DFA_HaploDFA_Haplo Join Date: 2003-01-21 Member: 12537Members
    Is it someday yet?

    just playin Mons <!--emo&:p--><img src='http://www.unknownworlds.com/forums/html/emoticons/tounge.gif' border='0' style='vertical-align:middle' alt='tounge.gif'><!--endemo-->
  • MonsieurEvilMonsieurEvil Join Date: 2002-01-22 Member: 4Members, Retired Developer, NS1 Playtester, Contributor
    Heh. I should be home at a decent hour tonight, and will take a couple minutes to look into this.
  • BonelessBoneless Join Date: 2002-09-03 Member: 1270Members
    I use Firedaemon Lite (1 service limitation) since I run a single server... and works like a charm... The problem comes out if you run more than one server on the same hardware, you will need Firedaemon Pro which costs $€$€...

    /me wonders why theres no free apps like Firedaemon Pro...
  • MonsieurEvilMonsieurEvil Join Date: 2002-01-22 Member: 4Members, Retired Developer, NS1 Playtester, Contributor
    Ok, so here's a goofy little proof of concept wrapper (I don;t feel like working today, if you haven't noticed). Now, this is just a small proof of concept and is very dirty (you will need to make a couple registry edits for it to work, so if you are incompetent or easily scared - run away!).

    Save this file to it's own directory. Then run the service installer to install it. Then open regedit, navigate to your new service:

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\(your servicename here)

    And on the key where it says 'Imagepath='(the executable path you had specified when you installed the service), add the following:

    The path to your hlds.exe AND the parameters you want to include with your hlds.exe IN QUOTES (this is miportant, in the proof of concept version).

    So an example would be: c:\sierra\half-life\hlds.exe "-game ns map ns_veil -maxplayers 16"

    Close regedit, and try and start your new service. Tell me how it goes (I have no access to hlds here and can;t test this at all, but if you tell me about your errors I can probably figure it out. Or I may give you a debug version).
  • MonsieurEvilMonsieurEvil Join Date: 2002-01-22 Member: 4Members, Retired Developer, NS1 Playtester, Contributor
    edited August 2003
    Also (Important!) - redownload the service installer - it had a mask set on the extension of exe, and this service wrapper must end with exs. Just overwrite your old service installer.
    ssi.exe 641.4K
  • DFA_HaploDFA_Haplo Join Date: 2003-01-21 Member: 12537Members
    Great I'll give this a try when I get home. Thanks.
  • DFA_HaploDFA_Haplo Join Date: 2003-01-21 Member: 12537Members
    edited August 2003
    MEH... The service installer still only shows exe extention files. I even downloaded it twice just to make sure. I tried changing the hldsservc.exs to .exe and that was a no go . *edit * meaning that the service still wouldnt start.*

    New service installer please.
  • MonsieurEvilMonsieurEvil Join Date: 2002-01-22 Member: 4Members, Retired Developer, NS1 Playtester, Contributor
    edited August 2003
    darnit I'm a dope. Here you go - the proper service installer. This one correctly shows EX* extensions and will allow you to install the wrapper service correctly.
    ssi.exe 641.4K
  • DFA_HaploDFA_Haplo Join Date: 2003-01-21 Member: 12537Members
    Well doing a little better. The service pretends like it starts it even says its started but you cannot connect to the server and I can even start another HLDS server manually and it dosent error out telling me the port is already in use. I wish there was some way to view the output of the service to see what exactly its doing.
  • MonsieurEvilMonsieurEvil Join Date: 2002-01-22 Member: 4Members, Retired Developer, NS1 Playtester, Contributor
    edited August 2003
    What's your HLDS commandline set to in the service? Also, when you load the hlds service, does it show the hlds.exe running in memory (in task mangler)? Also, what happens when you se the service Log on mode to 'allow to interact with desktop'? how about if you provide actual credentials rather than the service account?
  • DFA_HaploDFA_Haplo Join Date: 2003-01-21 Member: 12537Members
    Ok now I'm the dope and an idiot that can't follow directions very well. I missed the part in the registry about the image path pointing to the hlds.exe. I was too busy adding the parameters. Which now it looks like this
    C:\Sierra\Counter-Strike\hlds.exe "-game ns -map ns_caged -maxplayers 8"
    and with the interact with desktop set the HLDS window opens up and I get a Fatal HLDS error
    Fatal Error (shutting down) W_LoadWadFile: Couldn't Load gfx.wad

    Its the same HLDS.exe that I use when I manually start the server. So I dont know why all of the sudden it can't find the gfx.wad. (I can still start it manually)

    Don't let this drive you madd. It would be cool to have but I can live without it. I just offered to help since no one else was testing it.
  • MonsieurEvilMonsieurEvil Join Date: 2002-01-22 Member: 4Members, Retired Developer, NS1 Playtester, Contributor
    Ahhhh, I know exactly what that might be! Let me give you a replacement service wrapper, brb.
  • MonsieurEvilMonsieurEvil Join Date: 2002-01-22 Member: 4Members, Retired Developer, NS1 Playtester, Contributor
    Here, try this one. I use a more advanced run function that supports working directories and such. NT Services get very persnickity about trying to assume the environment at all in called applications. Let me know how it goes!
  • DFA_HaploDFA_Haplo Join Date: 2003-01-21 Member: 12537Members
    Still didn't like it. Got the same error. I have tried putting the service wrapper in the Dir with HLDS and in its own directory and same error messge both ways.
  • MonsieurEvilMonsieurEvil Join Date: 2002-01-22 Member: 4Members, Retired Developer, NS1 Playtester, Contributor
    /me shakes fist at hlds

    Ok, let me think on this a bit. Has to be something we can do...
  • ScytheScythe Join Date: 2002-01-25 Member: 46NS1 Playtester, Forum Moderators, Constellation, Reinforced - Silver
    /me prods MonsE

    Any luck?

    --Scythe--
  • FlurzFlurz Join Date: 2002-11-20 Member: 9428Members, Constellation
    Isn't google amazing <!--emo&:)--><img src='http://www.unknownworlds.com/forums/html/emoticons/smile.gif' border='0' style='vertical-align:middle' alt='smile.gif'><!--endemo-->

    <a href='http://www3.telus.net/mean/mean/04_serverloader.html' target='_blank'>http://www3.telus.net/mean/mean/04_serverloader.html</a>

    <!--QuoteBegin--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> </td></tr><tr><td id='QUOTE'><!--QuoteEBegin-->The (mEAn) ServerLoader will load up your HLDS server as a windows service. It can also be configured to load up other programs as a service, such as HLTV or any other program that normally does not run as a service. It will monitor each loaded service for failures and automatically restart them for you. It will allow you to log out of your Windows session without taking down the service. In addition, it will automatically restart your services whenever your server reboots - no manual intervention is needed! Works on Win2K and XP servers.

    * Automatically loads up your services on server start up and after unexpected restarts.

    Gives your server unattended 24/7 uptime by automatically restarting your services after failure.

    * Low profile installation, requires very little space and no registry settings.

    * Consumes negligible amounts of memory and CPU time.

    Simple command-line interface designed for server operators.<!--QuoteEnd--></td></tr></table><span class='postcolor'><!--QuoteEEnd-->
  • MonsieurEvilMonsieurEvil Join Date: 2002-01-22 Member: 4Members, Retired Developer, NS1 Playtester, Contributor
    I love reinventing the wheel... -_-

    Now if only he had posted source I could see why HLDS seems to hate the wrapper environment of my little EXE. Oh well, someone try this out and tell us how it went.
Sign In or Register to comment.