Running q as a service on Windows
SrvAny is a tool found in the Windows NT Resource Kit that is used for running Windows NT applications as services. You can download it from Microsoft site: .
To create a Windows NT user-defined service, perform the following steps: 1.Copy srvany.exe to c:\q 2. At command prompt(cmd.exe), type
instsrv.exe q5010 c:\q\srvany.exe
This will create service named q5010. We will use it to run q on port 5010(tickerplant)
3.Prepare Windows registry file to setup parameters for q5010 service:
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\q5010\Parameters] "Application"="c:\\q\\w32\\q.exe" "AppParameters"="-p 5010 -q" "AppDirectory"="c:\\q"
4. Now you can use q5010 service as usual windows service:
sc start q5010 or net start q5010
sc stop q5010 or net stop q5010
If you want setup several instances repeat steps 2-3 for different service names and ports. If you run tickerplant, realtime and historical database you will have 3 services at minimum, q5010, q5011, q5012. To start in appropriate order you can setup dependencies between q5011 and q5010
sc.exe q5011 depend= q5010
Note that sign '=' must be immediately after word depend and space before service name.
In this way you can setup on windows complete kdb setup that starts and stops in right way.
Also if you need to do redirect of output you must modify application using following reg file.
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\q5010\Parameters] "Application"="c:\\WINDOWS\\system32\\cmd.exe" "AppParameters"="/c c:\\q\\w32\\q.exe -p 5010 -q >c:\\q\\logs\\q.5010.log" "AppDirectory"="c:\\q"
I've experienced some problems with redirecting output, so it would be great if someone can update article to fix this.
1.Start regedit and go to following subkey:
2. Add Value with name AppEnvironment with type REG_MULTI_SZ
3. In the Multi-String Editor, enter environment variables using the syntax <variable name>=<value>.
Do not forget to add a new line after the last line, or the value will be ignored.