README.txt 6.3 KB

  1. NSSM: The Non-Sucking Service Manager
  2. Version 2.7, 2011-01-25
  3. NSSM is a service helper program similar to srvany and cygrunsrv. It can
  4. start any application as an NT service and will restart the service if it
  5. fails for any reason.
  6. NSSM also has a graphical service installer and remover.
  7. Full documentation can be found online at
  9. Since version 2.0, the GUI can be bypassed by entering all appropriate
  10. options on the command line.
  11. Since version 2.1, NSSM can be compiled for x64 platforms.
  12. Thanks Benjamin Mayrargue.
  13. Since version 2.2, NSSM can be configured to take different actions
  14. based on the exit code of the managed application.
  15. Since version 2.3, NSSM logs to the Windows event log more elegantly.
  16. Since version 2.5, NSSM respects environment variables in its parameters.
  17. Usage
  18. -----
  19. In the usage notes below, arguments to the program may be written in angle
  20. brackets and/or square brackets. <string> means you must insert the
  21. appropriate string and [<string>] means the string is optional. See the
  22. examples below...
  23. Installation using the GUI
  24. --------------------------
  25. To install a service, run
  26. nssm install <servicename>
  27. You will be prompted to enter the full path to the application you wish
  28. to run and any command line options to pass to that application.
  29. Use the system service manager (services.msc) to control advanced service
  30. properties such as startup method and desktop interaction. NSSM may
  31. support these options at a later time...
  32. Installation using the command line
  33. -----------------------------------
  34. To install a service, run
  35. nssm install <servicename> <application> [<options>]
  36. NSSM will then attempt to install a service which runs the named application
  37. with the given options (if you specified any).
  38. Don't forget to enclose paths in "quotes" if they contain spaces!
  39. Managing the service
  40. --------------------
  41. NSSM will launch the application listed in the registry when you send it a
  42. start signal and will terminate it when you send a stop signal. So far, so
  43. much like srvany. But NSSM is the Non-Sucking service manager and can take
  44. action if/when the application dies.
  45. With no configuration from you, NSSM will try to restart itself if it notices
  46. that the application died but you didn't send it a stop signal. NSSM will
  47. keep trying, pausing 30 seconds between each attempt, until the service is
  48. successfully started or you send it a stop signal.
  49. NSSM will look in the registry under
  50. HKLM\SYSTEM\CurrentControlSet\Services\<service>\Parameters\AppExit for
  51. string (REG_EXPAND_SZ) values corresponding to the exit code of the application.
  52. If the application exited with code 1, for instance, NSSM will look for a
  53. string value under AppExit called "1" or, if it does not find it, will
  54. fall back to the AppExit (Default) value. You can find out the exit code
  55. for the application by consulting the system event log. NSSM will log the
  56. exit code when the application exits.
  57. Based on the data found in the registry, NSSM will take one of three actions:
  58. If the value data is "Restart" NSSM will try to restart the application as
  59. described above. This is its default behaviour.
  60. If the value data is "Ignore" NSSM will not try to restart the application
  61. but will continue running itself. This emulates the (usually undesirable)
  62. behaviour of srvany. The Windows Services console would show the service
  63. as still running even though the application has exited.
  64. If the value data is "Exit" NSSM will exit gracefully. The Windows Services
  65. console would show the service as stopped. If you wish to provide
  66. finer-grained control over service recovery you should use this code and
  67. edit the failure action manually. Please note that Windows versions prior
  68. to Vista will not consider such an exit to be a failure. On older versions
  69. of Windows you should use "Suicide" instead.
  70. If the value data is "Suicide" NSSM will simulate a crash and exit without
  71. informing the service manager. This option should only be used for
  72. pre-Vista systems where you wish to apply a service recovery action. Note
  73. that if the monitored application exits with code 0, NSSM will only honour a
  74. request to suicide if you explicitly configure a registry key for exit code 0.
  75. If only the default action is set to Suicide NSSM will instead exit gracefully.
  76. Removing services using the GUI
  77. -------------------------------
  78. NSSM can also remove services. Run
  79. nssm remove <servicename>
  80. to remove a service. You will prompted for confirmation before the service
  81. is removed. Try not to remove essential system services...
  82. Removing service using the command line
  83. ---------------------------------------
  84. To remove a service without confirmation from the GUI, run
  85. nssm remove <servicename> confirm
  86. Try not to remove essential system services...
  87. Logging
  88. -------
  89. NSSM logs to the Windows event log. It registers itself as an event log source
  90. and uses unique event IDs for each type of message it logs. New versions may
  91. add event types but existing event IDs will never be changed.
  92. Because of the way NSSM registers itself you should be aware that you may not
  93. be able to replace the NSSM binary if you have the event viewer open and that
  94. running multiple instances of NSSM from different locations may be confusing if
  95. they are not all the same version.
  96. Example usage
  97. -------------
  98. To install an Unreal Tournament server:
  99. nssm install UT2004 c:\games\ut2004\system\ucc.exe server
  100. To remove the server:
  101. nssm remove UT2004 confirm
  102. Building NSSM from source
  103. -------------------------
  104. NSSM is known to compile with Visual Studio 6, Visual Studio 2005 and Visual
  105. Studio 2008.
  106. Credits
  107. -------
  108. Thanks to Bernard Loh for finding a bug with service recovery.
  109. Thanks to Benjamin Mayrargue ( for adding 64-bit support.
  110. Thanks to Joel Reingold for spotting a command line truncation bug.
  111. Thanks to Arve Knudsen for spotting that child processes of the monitored
  112. application could be left running on service shutdown, and that a missing
  113. registry value for AppDirectory confused NSSM.
  114. Licence
  115. -------
  116. NSSM is public domain. You may unconditionally use it and/or its source code
  117. for any purpose you wish.