Programming Guide   >   Servers   >   HOOPS Server

Advanced Setup

The quick_start directory of the HOOPS Communicator package contains the start_server script that will start a HOOPS Server using common settings and a bundled version of the NodeJS runtime. The bundled configuration is designed to work for most users out of the box. This guide moves beyond to provide insights on how to run the server in a variety of ways that provide greater control and monitoring capabilities.

This section assumes that you are using a system installed version of NodeJS and npm.

To get things started, first navigate to the appropriate directory in your installation and ensure all node dependencies have been installed:

cd <path/to/communicator>/server/node
npm install

Now that all of the Node dependencies have been installed, we need to compile our JavaScript from the TypeScript source code. Run the following:

npm run build

The server is now ready to start:

npm start

You can modify the start script in package.json to include a configuration file of your choice using the --config-file command-line option.

It can be useful to run the HOOPS Server as a background process with the use of a process manager tool. These tools provide easy ways to monitor, aggregate, and restart applications in the event of a crash. There are a variety of options available to accomplish this task depending on your needs and environment.

When running the HOOPS Server with a process manager tool, it is recommended to use absolute paths for configuration file values.

The PM2 Process Manager is a production-grade process manager for NodeJS applications. It provides a consistent cross-platform API for monitoring and restarting processes in the event of a failure.

After installing PM2 globally we can start HOOPS Server with the following command:

pm2 start ./lib/HttpServer.js --node-args="--expose-gc"

Additionally, PM2 is capable of starting processes when the system boots. Refer to the Startup Script section of the PM2 documentation for detailed information.

Systemd is available on most linux distributions and can be used to run HOOPS Communicator in the background. Begin by creating a file named communicator.service with the following content:

[Unit]
Description=communicator
[Service]
ExecStart=/usr/bin/node '--expose-gc' './lib/HttpServers.js'
Restart=always
User=<your user name>
# Note Debian/Ubuntu uses 'nogroup', RHEL/Fedora uses 'nobody'
Group=nogroup
Environment=PATH=/usr/bin:/usr/local/bin
WorkingDirectory=/path/to/Communicator/server/node
[Install]
WantedBy=multi-user.target

You will need to set the values between the < > to be relevant to your system. Once you have created the file, move it into the correct systemd folder:

sudo cp communicator.service /etc/systemd/system

You can now start the server by running:

sudo systemctl start communicator

Likewise, you can stop the server:

sudo systemctl stop communicator

You can also view the server log:

journalctl -u communicator.service -b