README.txt 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. NSSM: The Non-Sucking Service Manager
  2. Version 2.15, 2012-07-19
  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
  8. http://nssm.cc/
  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. Since version 2.8, NSSM tries harder to shut down the managed application
  18. gracefully and throttles restart attempts if the application doesn't run
  19. for a minimum amount of time.
  20. Since version 2.11, NSSM respects srvany's AppEnvironment parameter.
  21. Since version 2.13, NSSM is translated into French.
  22. Thanks François-Régis Tardy.
  23. Since version 2.15, NSSM is translated into Italian.
  24. Thanks Riccardo Gusmeroli.
  25. Usage
  26. -----
  27. In the usage notes below, arguments to the program may be written in angle
  28. brackets and/or square brackets. <string> means you must insert the
  29. appropriate string and [<string>] means the string is optional. See the
  30. examples below...
  31. Installation using the GUI
  32. --------------------------
  33. To install a service, run
  34. nssm install <servicename>
  35. You will be prompted to enter the full path to the application you wish
  36. to run and any command line options to pass to that application.
  37. Use the system service manager (services.msc) to control advanced service
  38. properties such as startup method and desktop interaction. NSSM may
  39. support these options at a later time...
  40. Installation using the command line
  41. -----------------------------------
  42. To install a service, run
  43. nssm install <servicename> <application> [<options>]
  44. NSSM will then attempt to install a service which runs the named application
  45. with the given options (if you specified any).
  46. Don't forget to enclose paths in "quotes" if they contain spaces!
  47. Managing the service
  48. --------------------
  49. NSSM will launch the application listed in the registry when you send it a
  50. start signal and will terminate it when you send a stop signal. So far, so
  51. much like srvany. But NSSM is the Non-Sucking service manager and can take
  52. action if/when the application dies.
  53. With no configuration from you, NSSM will try to restart itself if it notices
  54. that the application died but you didn't send it a stop signal. NSSM will
  55. keep trying, pausing between each attempt, until the service is successfully
  56. started or you send it a stop signal.
  57. NSSM will pause an increasingly longer time between subsequent restart attempts
  58. if the service fails to start in a timely manner, up to a maximum of four
  59. minutes. This is so it does not consume an excessive amount of CPU time trying
  60. to start a failed application over and over again. If you identify the cause
  61. of the failure and don't want to wait you can use the Windows service console
  62. (where the service will be shown in Paused state) to send a continue signal to
  63. NSSM and it will retry within a few seconds.
  64. By default, NSSM defines "a timely manner" to be within 1500 milliseconds.
  65. You can change the threshold for the service by setting the number of
  66. milliseconds as a REG_DWORD value in the registry at
  67. HKLM\SYSTEM\CurrentControlSet\Services\<service>\Parameters\AppThrottle.
  68. NSSM will look in the registry under
  69. HKLM\SYSTEM\CurrentControlSet\Services\<service>\Parameters\AppExit for
  70. string (REG_EXPAND_SZ) values corresponding to the exit code of the application.
  71. If the application exited with code 1, for instance, NSSM will look for a
  72. string value under AppExit called "1" or, if it does not find it, will
  73. fall back to the AppExit (Default) value. You can find out the exit code
  74. for the application by consulting the system event log. NSSM will log the
  75. exit code when the application exits.
  76. Based on the data found in the registry, NSSM will take one of three actions:
  77. If the value data is "Restart" NSSM will try to restart the application as
  78. described above. This is its default behaviour.
  79. If the value data is "Ignore" NSSM will not try to restart the application
  80. but will continue running itself. This emulates the (usually undesirable)
  81. behaviour of srvany. The Windows Services console would show the service
  82. as still running even though the application has exited.
  83. If the value data is "Exit" NSSM will exit gracefully. The Windows Services
  84. console would show the service as stopped. If you wish to provide
  85. finer-grained control over service recovery you should use this code and
  86. edit the failure action manually. Please note that Windows versions prior
  87. to Vista will not consider such an exit to be a failure. On older versions
  88. of Windows you should use "Suicide" instead.
  89. If the value data is "Suicide" NSSM will simulate a crash and exit without
  90. informing the service manager. This option should only be used for
  91. pre-Vista systems where you wish to apply a service recovery action. Note
  92. that if the monitored application exits with code 0, NSSM will only honour a
  93. request to suicide if you explicitly configure a registry key for exit code 0.
  94. If only the default action is set to Suicide NSSM will instead exit gracefully.
  95. Removing services using the GUI
  96. -------------------------------
  97. NSSM can also remove services. Run
  98. nssm remove <servicename>
  99. to remove a service. You will prompted for confirmation before the service
  100. is removed. Try not to remove essential system services...
  101. Removing service using the command line
  102. ---------------------------------------
  103. To remove a service without confirmation from the GUI, run
  104. nssm remove <servicename> confirm
  105. Try not to remove essential system services...
  106. Logging
  107. -------
  108. NSSM logs to the Windows event log. It registers itself as an event log source
  109. and uses unique event IDs for each type of message it logs. New versions may
  110. add event types but existing event IDs will never be changed.
  111. Because of the way NSSM registers itself you should be aware that you may not
  112. be able to replace the NSSM binary if you have the event viewer open and that
  113. running multiple instances of NSSM from different locations may be confusing if
  114. they are not all the same version.
  115. Example usage
  116. -------------
  117. To install an Unreal Tournament server:
  118. nssm install UT2004 c:\games\ut2004\system\ucc.exe server
  119. To remove the server:
  120. nssm remove UT2004 confirm
  121. Building NSSM from source
  122. -------------------------
  123. NSSM is known to compile with Visual Studio 6, Visual Studio 2005 and Visual
  124. Studio 2008.
  125. NSSM will also compile with Visual Studio 2010 but the resulting executable
  126. will not run on versions of Windows older than XP SP2.
  127. Credits
  128. -------
  129. Thanks to Bernard Loh for finding a bug with service recovery.
  130. Thanks to Benjamin Mayrargue (www.softlion.com) for adding 64-bit support.
  131. Thanks to Joel Reingold for spotting a command line truncation bug.
  132. Thanks to Arve Knudsen for spotting that child processes of the monitored
  133. application could be left running on service shutdown, and that a missing
  134. registry value for AppDirectory confused NSSM.
  135. Thanks to Peter Wagemans and Laszlo Keresztfalvi for suggesting throttling restarts.
  136. Thanks to Eugene Lifshitz for finding an edge case in CreateProcess() and for
  137. advising how to build messages.mc correctly in paths containing spaces.
  138. Thanks to Rob Sharp for pointing out that NSSM did not respect the
  139. AppEnvironment registry value used by srvany.
  140. Thanks to Szymon Nowak for help with Windows 2000 compatibility.
  141. Thanks to François-Régis Tardy for French translation.
  142. Thanks to Emilio Frini for spotting that French was inadvertently set as
  143. the default language when the user's display language was not translated.
  144. Thanks to Riccardo Gusmeroli for Italian translation.
  145. Licence
  146. -------
  147. NSSM is public domain. You may unconditionally use it and/or its source code
  148. for any purpose you wish.