Table of Contents
Starting TransSECS deployments automatically on Windows
A TransSECS deployment is the folder TransSECS builds for a project. It holds <ProjectName>Runtime.jar, ErgoTechConfiguration.properties, log4j2.xml and run.bat. Double-clicking run.bat starts the deployment in a console window. It stops when that window is closed, Ctrl+C is pressed in it, or the user logs off.
There are two ways to have a deployment start without anyone double-clicking run.bat:
| Startup folder | Windows service | |
|---|---|---|
| Starts | when the user logs in | when Windows starts, before anyone logs in |
| Console window | visible, like a hand-started deployment | none; output goes to log files |
| If the deployment stops | it stays stopped | Windows can restart it |
| When the user logs off | the deployment stops | the deployment keeps running |
| Setting it up | drag one shortcut, no extra software | a Java copy, the WinSW wrapper and an .xml file; needs Administrator rights |
Use the Startup folder on a machine where someone is always logged in and you want to see the console. Use a Windows service on an unattended machine, or where the deployment must keep running through log-offs and restart after a failure.
Before either: start the deployment once by hand with run.bat, on this machine, and check that it connects and that the log shows Valid IOT System Runtime License detected. See Running TransSECS deployments on the bottom half of this page. Licence and configuration problems are much easier to see in a console window.
1. Start the deployment when you log in (Startup folder)
- Press Windows key + R, type
shell:startupand press Enter. This opens your own Startup folder. To start the deployment for every user who logs in, typeshell:common startupinstead. Adding to that folder needs Administrator rights. - In File Explorer, open the deployment folder.
- Drag
run.batinto the Startup folder with the right mouse button, and choose Create shortcuts here. Do not copy or moverun.batitself. It must run inside the deployment folder, because that is where it finds the runtime jar, the licence and the settings. - Check the shortcut: right-click it, choose Properties, and make sure Start in is the deployment folder. Dragging fills this in for you.
- Optional: in the same Properties window, set Run to Minimized, so that the console window starts on the taskbar.
- Log off and log in again to check that the deployment starts.
Things to know:
- Nothing starts until someone logs in. After a power cut or a Windows update restart, the deployment stays stopped until a user logs in. If that is not acceptable, use a service instead.
- Closing the console window stops the deployment. So does logging off.
- To stop it starting automatically, delete the shortcut from the Startup folder. The deployment itself is not affected.
- Several deployments: add one shortcut per deployment. Two deployments on one machine must not use the same HSMS port.
2. Run the deployment as a Windows service
A Windows service starts with Windows, runs without a console window or a logged-in user, and can be restarted automatically if it stops. TransSECS uses WinSW 2.12.0, a small open-source program that runs a command as a Windows service.
In outline:
- Give the deployment its own Java. Copy the
jrefolder from<TransSECS installation>\MIStudioSuite\jreinto the deployment folder, so that<deployment>\jre\bin\java.exeexists. A service does not use your PATH, and a copy keeps the service working when TransSECS is upgraded or removed. - Add the wrapper. Copy
WinSW-x64.exeinto the deployment folder and rename it, for example toGEMHostService.exe. - Configure it. Next to the
.exe, create an.xmlfile with the same base name (GEMHostService.xml). It names the service, the Java command line taken fromrun.bat, the start mode, what to do on failure, and how the log files roll over. - Install and start it. In a Command Prompt opened as Administrator in the deployment folder, run
GEMHostService.exe install, thenGEMHostService.exe start. - Check it.
GEMHostService.exe statusshould sayStarted. The console output is written toGEMHostService.out.logandGEMHostService.err.login the deployment folder.
After that, the service can be started and stopped from the Services window (services.msc) like any other.
The full instructions, with an example .xml file to copy, what each setting does, how to change and remove the service, and what to check when it does not start, are on Running a TransSECS deployment as a Windows service.
3. Removing automatic start before you uninstall
Remove the Startup shortcut or the service before you delete a deployment folder or the TransSECS installation:
- Startup folder: delete the shortcut.
- Service: in a Command Prompt as Administrator in the deployment folder, run
GEMHostService.exe stop, thenGEMHostService.exe uninstall.
Otherwise Windows keeps trying to start a program that no longer exists. The uninstall-readme.txt file in the TransSECS installation folder (also opened by How to Uninstall in the ErgoTech Start menu folder) lists the other steps.
