Page 1 of 1

Trackmania Server as Windows Service

Posted: 16 Jul 2009 17:50
by Scordo
Hello Server-Owners,

during development of TMSPS I've created a windows service which enables you to run the trackmania dedicated server under windows as a windows service. First I wrote it for my personal use, but I think most of the windows server owners will need it. So I've created a release today. You can download it here:

http://tmsps.codeplex.com/Release/Proje ... seId=30257

Description:
The Trackmania Service Wrapper is a wrapper service for the trackmania dedicated server software. It allows you to run the trackmania dedicated server software as a windows service.

Requirements:
  • .Net 3.5

Advantage
  • auto restart of crashed trackmania server
  • possibility to provide a web frontend to start/stop the service (already developed but no release currently)
I've already written an ASP.Net web frontent to start/stop the trackmania server using the browser, but there is no documentation on how to install it. That's why it isn't released yet. But I'll hopefully release it within the next week.

Suggestions/Criticism/Feedback is welcome!
Scordo

Re: Trackmania Server as Windows Service

Posted: 16 Jul 2009 21:37
by matzi
wow
good work, go on :thumbsup:

Re: Trackmania Server as Windows Service

Posted: 16 Jul 2009 23:49
by Scordo
matzi wrote:wow
good work, go on :thumbsup:
Thanks! :1

Re: Trackmania Server as Windows Service

Posted: 17 Jul 2009 05:15
by Assembler Maniac
I can write a pretty simple installer that takes the path for TrackmaniaServer.exe (without the filename), and appropriate parms, and turns it into a service.

DOS Command "net start SVCNAME" or "net stop SVCNAME" can be used to start/stop a service fairly easily.

Could probably even prompt for the arguments too.

Anyone interested in this?

No .net needed either.

Re: Trackmania Server as Windows Service

Posted: 17 Jul 2009 11:13
by lille79
Assembler Maniac wrote: Anyone interested in this?
:thumbsup:

Re: Trackmania Server as Windows Service

Posted: 17 Jul 2009 20:07
by nocturne
What about using sc.exe to install as a service..?
sc create [service name] [binPath= ] <option1> <option2>...
CREATE OPTIONS:
NOTE: The option name includes the equal sign.
type= <own|share|interact|kernel|filesys|rec>
(default = own)
start= <boot|system|auto|demand|disabled>
(default = demand)
error= <normal|severe|critical|ignore>
(default = normal)
binPath= <BinaryPathName>
group= <LoadOrderGroup>
tag= <yes|no>
depend= <Dependencies(separated by / (forward slash))>
obj= <AccountName|ObjectName>
(default = LocalSystem)
DisplayName= <display name>
password= <password>
Another nifty little app is XYNTService, which will let you set up a single service to start up multiple process in a specific order with/without timeouts.

Re: Trackmania Server as Windows Service

Posted: 17 Jul 2009 22:15
by Generator
Assembler Maniac wrote:I can write a pretty simple installer that takes the path for TrackmaniaServer.exe (without the filename), and appropriate parms, and turns it into a service.

DOS Command "net start SVCNAME" or "net stop SVCNAME" can be used to start/stop a service fairly easily.

Could probably even prompt for the arguments too.

Anyone interested in this?

No .net needed either.
Do you know about Microsoft's SC command Assembler Maniac? 'SC.exe' can give you alot more options and is dedicated to dealing with services. :thumbsup:

net start/stop is a little bit more limited. :wink:

Code: Select all

DESCRIPTION:
        SC is a command line program used for communicating with the
        Service Control Manager and services.
USAGE:
        sc <server> [command] [service name] <option1> <option2>...


        The option <server> has the form "\\ServerName"
        Further help on commands can be obtained by typing: "sc [command]"
        Commands:
          query-----------Queries the status for a service, or
                          enumerates the status for types of services.
          queryex---------Queries the extended status for a service, or
                          enumerates the status for types of services.
          start-----------Starts a service.
          pause-----------Sends a PAUSE control request to a service.
          interrogate-----Sends an INTERROGATE control request to a service.
          continue--------Sends a CONTINUE control request to a service.
          stop------------Sends a STOP request to a service.
          config----------Changes the configuration of a service (persistent).
          description-----Changes the description of a service.
          failure---------Changes the actions taken by a service upon failure.
          failureflag-----Changes the failure actions flag of a service.
          sidtype---------Changes the service SID type of a service.
          privs-----------Changes the required privileges of a service.
          qc--------------Queries the configuration information for a service.
          qdescription----Queries the description for a service.
          qfailure--------Queries the actions taken by a service upon failure.
          qfailureflag----Queries the failure actions flag of a service.
          qsidtype--------Queries the service SID type of a service.
          qprivs----------Queries the required privileges of a service.
          qtriggerinfo----Queries the trigger parameters of a service.
          qpreferrednode--Queries the preferred NUMA node of a service.
          delete----------Deletes a service (from the registry).
          create----------Creates a service. (adds it to the registry).
          control---------Sends a control to a service.
          sdshow----------Displays a service's security descriptor.
          sdset-----------Sets a service's security descriptor.
          showsid---------Displays the service SID string corresponding to an arbitrary name.
          triggerinfo-----Configures the trigger parameters of a service.
          preferrednode---Sets the preferred NUMA node of a service.
          GetDisplayName--Gets the DisplayName for a service.
          GetKeyName------Gets the ServiceKeyName for a service.
          EnumDepend------Enumerates Service Dependencies.

        The following commands don't require a service name:
        sc <server> <command> <option>
          boot------------(ok | bad) Indicates whether the last boot should
                          be saved as the last-known-good boot configuration
          Lock------------Locks the Service Database
          QueryLock-------Queries the LockStatus for the SCManager Database
EXAMPLE:
        sc start MyService
http://support.microsoft.com/kb/251192


EDIT: Sorry Nocturne, didn't notice the line above the quotes on your post! :oops:
I just saw the 3rd party app recommendation. My Bad...

Re: Trackmania Server as Windows Service

Posted: 17 Jul 2009 23:46
by nocturne
Generator wrote:net start/stop is a little bit more limited. :wink:
Those just start/stop the service, once installed. Easiest route to creating simple restart/stop batch files.

Also, can always just add it by hand to the registry, in case you find yourself lost in long dos commands.

Re: Trackmania Server as Windows Service

Posted: 18 Jul 2009 04:52
by Assembler Maniac
Batch files would be difficult to use, at best, if you're managing multiple servers. Creating/deleting/starting/stopping would be much easier if there was a simple manager for it.

How about a Delphi app (single EXE, no DLLs required) to manage your TMFServer Services?

I hope to have it done over the weekend.

It will list any servers it finds (TMFServerNN where NN is 00 to 99), it's status (running/stopped), let you start/restart/stop it, and let you create/destroy them. All with ability to pick the startup files (config & matchsettings), and set the LAN and AutoQuit options.

Installer will create desktop shortcut, and install the manager & srvany.exe (necessary to run trackmaniaserver.exe as a service) in the trackmaniaserver directory.

Re: Trackmania Server as Windows Service

Posted: 19 Jul 2009 06:17
by Assembler Maniac
Unzip http://www.pchotshots.com/amaniac/tmfsvcmgr.zip into your trackmaniaserver.exe directory. You *MUST* use the same directory, otherwise it will NOT work.

nssm.exe is used to actually run the server. (it handles the service calls)

Once you run TMFSvcMgr, you'll see a blank grid. Right click anywhere for the menu.

It should be pretty easy to figure out. After editing an existing server, you'll need to stop/restart to get the changes to take effect.

I'm kinda wiped right now, can some brave person download it and try it out?

Interaction with desktop is turned on at the moment, so you should see the server actually running. I might make this a config option.

Closing the server window (ctrl-break or X) will NOT stop the service - TrackmaniaServer WILL be restarted automatically!

I'll add a readme.txt when I have some time.

[edit] - changed srvany.exe to nssm.exe, made note that killing trackmaniaserver.exe will result in it being restarted.

Re: Trackmania Server as Windows Service

Posted: 19 Jul 2009 15:46
by ЭΛ GAS〄SőŁのเē尺
Nice! :thumbsup:

Re: Trackmania Server as Windows Service

Posted: 19 Jul 2009 15:57
by Assembler Maniac
I've made a change.

I found a better program than srvany.exe, it's called NSSM (Non-Sucking Service Manager) and it will restart a server if it crashes out, and it writes helpful events into the application event log (like when it has to restart an app that crashed).

New version avail in same zip file.

Re: Trackmania Server as Windows Service

Posted: 24 Jul 2009 01:16
by Mort
Good stuff, I was just about to start testing mine with svrany so this might be a good alternative.

I do have a quesiton though: How does it handle also starting FAST or other server managers as services also?

Re: Trackmania Server as Windows Service

Posted: 24 Jul 2009 03:36
by Assembler Maniac
Mort wrote:Good stuff, I was just about to start testing mine with svrany so this might be a good alternative.

I do have a quesiton though: How does it handle also starting FAST or other server managers as services also?
Haven't done anything about that yet, but I've been wondering if one service could handle 2 processes. I'll post back if I come up with something. (maybe a custom version of nssm that handles 2 applications)