Starting and Ending Profound.js Instances

Starting and Ending Profound.js Instances

Overview

How a Profound.js instance is started depends on the platform. On IBM i, instances are normally controlled with the STRTCPSVR and ENDTCPSVR commands and are described by an instance configuration file on the IFS. On Windows, Linux, and other servers, the instance is started directly with Node.js.

A restart is required whenever config.js is changed (see Configuration File).

On IBM i

Instances can be started and ended with the STRTCPSVR and ENDTCPSVR commands. This requires that the question Control server instance using STRTCPSVR/ENDTCPSVR commands? was answered with ‘y’ when Profound.js was installed (see Installation Process).

Starting Instances

To start all Profound.js instances:

STRTCPSVR SERVER(*PJS) INSTANCE(*ALL)

To start an individual instance, name it on the INSTANCE parameter. Substitute your own instance name if it is not the default PROFOUNDJS:

STRTCPSVR SERVER(*PJS) INSTANCE(PROFOUNDJS)

Instances can also be set up at installation time to start automatically when TCP/IP is started. That setting is stored as the autostart directive in the instance configuration file, described below.

Ending Instances

To end all instances:

ENDTCPSVR SERVER(*PJS) INSTANCE(*ALL)

To end an individual instance named PROFOUNDJS:

ENDTCPSVR SERVER(*PJS) INSTANCE(PROFOUNDJS)

Each running instance appears as an active job in the PROFOUNDJS subsystem, which is a quick way to confirm whether a start or end command took effect (see Verifying the Installation).

Instance Configuration File

The installer creates an instance configuration file on the IFS at /profoundjs-base/instances/INSTANCE_NAME/conf. This file tells the STRTCPSVR process how to launch the instance; it is separate from config.js, which configures the Profound.js server itself.

Directives are specified one per line, with an equal sign separating the directive name and its value. Directive names are case-sensitive.

Available Directives

  • path - The path to the start.js file in the Profound.js installation directory. This directive is set by the installer and does not normally need to be changed; adjust it only if the installation directory is moved after installation.

  • autostart - Whether the instance starts automatically when TCP/IP starts. Set to 1 to autostart; set to 0 or remove the directive to disable it. The installer prompts for this setting at install time.

  • nodePath - The path to the Node.js binary used to run the instance. This is how a specific Node.js version is selected for an instance – for example /QOpenSys/pkgs/lib/nodejs22/bin/node.

  • ccsid - The CCSID used for the Profound.js server job and its associated SQL server (QSQSRVR) jobs. Use the same value you use with your existing IBM i applications so that character conversion is correct. If the directive is not specified, *USRPRF is used, which takes the CCSID from the PROFOUNDJS user profile.

  • nodeArgs - Arguments passed to Node.js when the instance is started with STRTCPSVR. Separate multiple arguments with a space on the same line; spaces within an individual argument value are not supported.

  • args - Arguments passed to Profound.js when the instance is started with STRTCPSVR. Separate multiple arguments with a space on the same line; spaces within an individual argument value are not supported.

  • env - Sets an environment variable for the instance job, in the form NAME=VALUE. Repeat the directive to set more than one variable. Unlike nodeArgs and args, any spaces on the line are kept as part of the value.

  • logging - Set to 0 to disable the STRTCPSVR process manager’s stdout/stderr logs. Starting in Profound.js 7.6.0, the Profound.js process writes its own stdout/stderr log files by default through the logging configuration option, so logging=0 avoids a duplicate set of log files.

Version requirements for the newer directives: nodeArgs requires Profound.js 4.8.0 or higher, args requires 4.13.0 or higher, env requires 5.8.0 or higher, and logging requires 7.6.0 or higher.

Example: A Typical Instance Configuration File

The file below is what a Profound.js 7 instance on IBM i usually looks like after installation. It starts the instance automatically with TCP/IP, pins it to Node.js 22, runs the job under CCSID 37, and turns off the duplicate process manager logs.

/profoundjs-base/instances/INSTANCE_NAME/conf

# Path to start.js in the installation directory (set by the installer) path=/profoundjs/start.js # Start this instance automatically when TCP/IP starts autostart=1 # Run the instance under Node.js 22 rather than the system default nodePath=/QOpenSys/pkgs/lib/nodejs22/bin/node # Match the CCSID used by the existing IBM i applications ccsid=37 # Profound.js writes its own stdout/stderr logs, so skip the process manager logs logging=0

Example: Raising the Node.js Memory Limit

Large workloads can exhaust the default Node.js heap. The nodeArgs directive passes options straight through to Node.js – here the old-space limit is raised to 8 GB. Add the line to the instance configuration file and restart the instance with ENDTCPSVR/STRTCPSVR for it to take effect.

nodeArgs=--max-old-space-size=8192

Example: Setting Environment Variables

Use env when the instance job needs an environment variable – for example to point Node.js at an extra certificate authority bundle so outbound HTTPS calls to an internal service are trusted. Repeat the directive once per variable.

env=NODE_EXTRA_CA_CERTS=/path/to/certs env=ANOTHER_VAR=myValue

On Your Local PC or Another Server

To start Profound.js on a local PC or a non-IBM i server – or on IBM i when you chose not to control the instance with STRTCPSVR/ENDTCPSVR – run the following command from the Profound.js installation directory:

node start.js

In a Unix shell or a command prompt window, press Ctrl-C to end the process.

If you are running on Windows, also see Allowing Connections in Windows Firewall.

To keep an instance running as a managed background service on a non-IBM i server, see Autostart Profoundjs with PM2.