NSSM 2.3
[nssm.git] / README.txt
1 NSSM: The Non-Sucking Service Manager\r
2 Version 2.3, 2010-04-21\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 \r
26 Usage\r
27 -----\r
28 In the usage notes below, arguments to the program may be written in angle \r
29 brackets and/or square brackets.  <string> means you must insert the \r
30 appropriate string and [<string>] means the string is optional.  See the \r
31 examples below...\r
32 \r
33 \r
34 Installation using the GUI\r
35 --------------------------\r
36 To install a service, run\r
37 \r
38     nssm install <servicename>\r
39 \r
40 You will be prompted to enter the full path to the application you wish \r
41 to run and any command line options to pass to that application.\r
42 \r
43 Use the system service manager (services.msc) to control advanced service \r
44 properties such as startup method and desktop interaction.  NSSM may \r
45 support these options at a later time...\r
46 \r
47 \r
48 Installation using the command line\r
49 -----------------------------------\r
50 To install a service, run\r
51 \r
52     nssm install <servicename> <application> [<options>]\r
53 \r
54 NSSM will then attempt to install a service which runs the named application \r
55 with the given options (if you specified any).\r
56 \r
57 Don't forget to enclose paths in "quotes" if they contain spaces!\r
58 \r
59 \r
60 Managing the service\r
61 --------------------\r
62 NSSM will launch the application listed in the registry when you send it a \r
63 start signal and will terminate it when you send a stop signal.  So far, so \r
64 much like srvany.  But NSSM is the Non-Sucking service manager and can take \r
65 action if/when the application dies.\r
66 \r
67 With no configuration from you, NSSM will try to restart itself if it notices\r
68 that the application died but you didn't send it a stop signal.  NSSM will\r
69 keep trying, pausing 30 seconds between each attempt, until the service is\r
70 successfully started or you send it a stop signal.\r
71 \r
72 NSSM will look in the registry under\r
73 HKLM\SYSTEM\CurrentControlSet\Services\<service>\Parameters\AppExit for\r
74 string (REG_SZ) values corresponding to the exit code of the application.\r
75 If the application exited with code 1, for instance, NSSM will look for a\r
76 string value under AppExit called "1" or, if it does not find it, will\r
77 fall back to the AppExit (Default) value.  You can find out the exit code\r
78 for the application by consulting the system event log.  NSSM will log the\r
79 exit code when the application exits.\r
80 \r
81 Based on the data found in the registry, NSSM will take one of three actions:\r
82 \r
83 If the value data is "Restart" NSSM will try to restart the application as\r
84 described above.  This is its default behaviour.\r
85 \r
86 If the value data is "Ignore" NSSM will not try to restart the application\r
87 but will continue running itself.  This emulates the (usually undesirable)\r
88 behaviour of srvany.  The Windows Services console would show the service\r
89 as still running even though the application has exited.\r
90 \r
91 If the value data is "Exit" NSSM will exit.  The Windows Services console\r
92 would show the service as stopped.  If you wish to provide finer-grained\r
93 control over service recovery you should use this code and edit the failure\r
94 action manually.\r
95 \r
96 \r
97 Removing services using the GUI\r
98 -------------------------------\r
99 NSSM can also remove services.  Run\r
100 \r
101     nssm remove <servicename>\r
102 \r
103 to remove a service.  You will prompted for confirmation before the service \r
104 is removed.  Try not to remove essential system services...\r
105 \r
106 \r
107 Removing service using the command line\r
108 ---------------------------------------\r
109 To remove a service without confirmation from the GUI, run\r
110 \r
111     nssm remove <servicename> confirm\r
112 \r
113 Try not to remove essential system services...\r
114 \r
115 \r
116 Logging\r
117 -------\r
118 NSSM logs to the Windows event log.  It registers itself as an event log source\r
119 and uses unique event IDs for each type of message it logs.  New versions may\r
120 add event types but existing event IDs will never be changed.\r
121 \r
122 Because of the way NSSM registers itself you should be aware that you may not\r
123 be able to replace the NSSM binary if you have the event viewer open and that\r
124 running multiple instances of NSSM from different locations may be confusing if\r
125 they are not all the same version.\r
126 \r
127 \r
128 Example usage\r
129 -------------\r
130 To install an Unreal Tournament server:\r
131 \r
132     nssm install UT2004 c:\games\ut2004\system\ucc.exe server\r
133 \r
134 To remove the server:\r
135 \r
136     nssm remove UT2004 confirm\r
137 \r
138 \r
139 Building NSSM from source\r
140 -------------------------\r
141 NSSM is known to compile with Visual Studio 6, Visual Studio 2005 and Visual\r
142 Studio 2008.\r
143 \r
144 \r
145 Credits\r
146 -------\r
147 Thanks to Benjamin Mayrargue (www.softlion.com) for adding 64-bit support.\r
148 Thanks to Joel Reingold for spotting a command line truncation bug.\r
149 \r
150 Licence\r
151 -------\r
152 NSSM is public domain.  You may unconditionally use it and/or its source code \r
153 for any purpose you wish.\r