ThingWorx WebSocket-based Edge MicroServer (WS EMS) and Lua Script Resource (LSR) > Running the ThingWorx WS EMS
  
Running the ThingWorx WS EMS
The ThingWorx WS EMS can be run either from a command line or as a Linux daemon or Windows service to establish a to ThingWorx platform.
Running WS EMS from a Command Line
The WS EMS can be run from a command line as follows:
1. Open a command window or terminal session on the system or device that is hosting the WS EMS.
2. Change to the directory, \microserver\etc.
3. For a basic configuration, copy the file, config.json.minimal, and rename it to config.json. Even for a complex configuration, start with your basic config.json file to ensure first that you can run the WS EMS.
* 
Do not attempt to use config.json.documented as is to run your WS EMS. It is intended as a reference, not as a valid JSON file that you can use to run WS EMS. Instead, use config.json.complete to run WS EMS using all available properties. Make sure that you save config.json.complete as config.json , and set all of the minimally required properties (see the next step).
4. Set the configuration properties:
For a simple configuration that establishes a connection to ThingWorx platform, see the section, Creating a Configuration File.
For a more complex configuration, start with the section, Creating a Configuration File, and then continue to the section, Viewing All Configuration Options.
5. Save the configuration file as config.json.
* 
The configuration file must be named config.json and reside in the \microserver\etc folder.
6. Change directories back to the top-level directory, \microserver.
You are ready to run the WS EMS, as follows:
1. To run the WS EMS, enter the command, wsems.
As part of initialization, the WS EMS checks the configuration file settings. Once initialized, the WS EMS prints its version number to the console and log file, attempts to connect to ThingWorx platform, and returns a message that the connection was successful to the console. You can tell that WS EMS is running and connected to ThingWorx platform by looking at the console prompt — two plus signs (++) indicate that it is running and connected.
2. Should you need to shut down the WS EMS, press ENTER to display the console prompt and type q.
* 
The Windows-based operating systems have a tick resolution (15ms) that is higher than the tick resolutions requested by the C SDK (5ms). For information about achieving the best performance in a Windows-based operating system, see Running on a Windows-based Operating System.
Running WS EMS as a Daemon (Linux) or as a Windows Service
To run WS EMS and the LSR as daemons or services, you first need to "install" them and then you can start them as you would any other daemon or service. Follow these steps:
1. Open a command window or terminal session on the system or device that is hosting the WS EMS.
2. Change to the \microserver\etc directory.
3. For a basic configuration, copy the file, config.json.minimal, and rename it to config.json. Even for a complex configuration, start with your basic config.json file to ensure that you can run WS EMS.
* 
Do not attempt to use config.json.documented as is to run your WS EMS. It is intended as a reference, not as a valid JSON file that you can use to run WS EMS. Instead, use config.json.complete to run WS EMS using all available properties. Make sure that you save config.json.complete as config.json , and set at least all of the minimally required properties (see the next step).
4. Set the configuration properties:
For a simple configuration that establishes a connection to ThingWorx platform, see Create the WS EMS Configuration File and Configure the Connection to ThingWorx Platform.
For a more complex configuration, start with the section, Create the WS EMS Configuration File, and then continue to the section, Additional Configuration Options.
5. Save the configuration file as config.json.
* 
The configuration file must be named config.json and reside in the \microserver\etc folder.
6. Follow the steps for your operating system:
For Windows:
1. Change into the \microserver\install_services\ directory.
2. Run the following command to install WS EMS and LSR as Windows services, with or without the options to create custom names:
install.bat [-wsems your_name_for_wsems_service_here]
[-lsr your_name_for_lsr_service_here]
Use only one hyphen (-) for the options. There is a space between the option and the argument, but for Windows, you must use the full option name.
For Linux:
1. Change to the \microserver\install_services\ directory.
2. To make the install script executable, use the following command:
sudo chmod +x microserver/install_services/install
3. Run one of the following commands to install the WS EMS and LSR as daemons:
Linux, using short names for the options
sudo ./microserver/install_services/install \
[-w your_name_for_ws_ems_service_here] \
[-l your_name_for_lsr_service_here]
Use only one hyphen (-) for the options. There is a space between the option and the argument.
Linux, using long names for the options:
sudo ./microserver/install_services/install \
[--wsems=your_name_for_ws_ems_service_here] \
[--lsr=your_name_for_lsr_service_here]
Note that the long options require two hyphens (--) before the option name, an equal sign following the name, and no space between the equal sign and the argument (your name for the service).
* 
To uninstall the service, remove the service from /etc/init.d/<Service Name>.
As part of initialization, the WS EMS checks the configuration file settings. Once initialized, the WS EMS prints its version number to the console and log file, attempts to connect to WS EMS, and returns a message that the connection was successful to the console. You can tell that WS EMS is running and connected to ThingWorx platform by looking at the console prompt — two plus signs (++) indicate that it is running and connected.