- Jul. 09, 2011
|Example files with this article:|
When you install a TM1 Server, you need a service for the Admin Services and for the TM1 Server. Multiple TM1 Servers could be running on the same machine. The Admin Server takes care of all the servers and the "administration" behind the scenes. For instance, servers available for use will register with the Admin server, such that TM1 users are able to see the TM1 Servers in their application.
The TM1 setup process to install a TM1 Server takes care of creating the services. However, as a TM1 Developer or Admin guy/gal, you frequently need to create services on the fly. Often, a backup copy of a model from a TM1 customer is set up in a test environment in order to do tests or diagnose / solve a certain issue.
A TM1 Service can be created and removed from command line. However, the syntax for the parameters escapes me so often. I wrote a small batch process to create or remove a service. Here it is.
Batch file code
Create a new text file. Choose a filename of your liking but change the extension to .BAT. Then, Edit the file with a text editor like Notepad. Add the following contents using copy-paste:
REM Wim Gielis REM http://www.wimgielis.comREM Choose 1 to create the specified service, REM any other value to remove it set vCreateRemove=1 set vServiceName="Customer X" set vDataDirectory="C:\…" set vAccountName="Domain\Username" set vAccountPassword="Password for this account" cd "C:\Program Files\Cognos\TM1\bin" IF %vCreateRemove%==1 (tm1sd -install -n%vServiceName% -z%vDataDirectory% -u%vAccountName% -w%vAccountPassword%) ELSE (tm1sd -remove -n%vServiceName%)
If you find it easier, right-click the file and Save the zip-file on top of the page.
Understanding the code
It is not too difficult to understand the above coding. In the upper part of the file, 5 parameters are to be filled in for the parameters:
- Do you want to create (choose 1) or remove (all else) a service?
- What name do you want to assign to the service?
- What is the Data directory for that TM1 Server?
- Under what account should the service run?
- What is the associated password for that account?
We enclose the parameter contents with double quotes whenever they contain spaces. Without spaces, adding quotes is optional. When everything was filled in correctly, save and close the .BAT file and execute it once.
In case the execution of the batch process returns errors, this usually pertains to:
- Typos in the parameters, whenever possible use copy-paste
- A tm1s.cfg file is missing in the data directory you specified
- A tm1s.cfg file has bad contents, such as a wrong data directory or non-existing log file directory
- A tm1s.lic file is missing in the data directory you specified
You can use several data directories for 1 TM1 model. In fact, what you specify above for parameter -z is the location of the TM1s.cfg file. Within that file, 1 or more valid data directories can be specified.
After the service was created, you need to start it. So, go to the Services panel (Run command, services.msc). Before starting the service you created, change its Startup type to Automatic (in the Properties). After that, you can start the service.
To start or stop a TM1 service from command line or in a batch process, use (without < and > characters):
net start <servicename> net stop <servicename>
To ask Windows information about your TM1 model, you could use in a command prompt:
sc queryex <servicename>
This could be useful because queryex gives you the Process Identifier (PID), which can be used to kill your TM1 model:
taskkill / <PID> /F
If the same machine hosts 2 or more TM1 servers (different services, like 1 for production, 1 for acceptance, 1 for development, …), it will be difficult to see which process pertains to which TM1 instance. In these cases the command line code proves useful. In newer Windows OS, Task Manager shows the PID information as well, e.g. for the process tm1sd.exe, and makes life easier.
Time for a break!
If you start the service of a big TM1 model, you can now get a few cups of coffee since this may take some time.