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