Using the NSD (Windows)
This page describes how to use the Network Service Daemon (NSD) with the InterSystems Web Gateway on Microsoft Windows. This is not the typical installation but is appropriate in some cases.
When to Use the NSD
There are three situations in which you might choose to use the NSD to separate the Web Gateway from the web server so that you can manage the Web Gateway independently of the web server:
-
If your web server distributes its load over multiple server processes, an instance of the Web Gateway is then attached to each web server process.
-
If you have a very large web server installation for which CSP is only a small part; for example, a web server that serves php, static content, .NET, and .ASP applications, as well as web applications.
-
If you are using the Nginx web server.
NSD Module Install Locations
If you use the NSD Module in Microsoft Windows, you install the following two utilities:
-
CSPnsd.exe
-
CSPnsdSv.exe
On an IIS installation, these are installed in this location:
C:\Inetpub\CSPGateway\nsd
On an Apache installation, these are installed in this location:
C:\Program Files\Apache Group\Apache\WebGateway\nsd
Run the NSD from within its home directory, C:\Inetpub\CSPGateway\nsd. The configuration file and the log file are written in this directory for NSD-based connectivity options.
Operating the NSD
Use the following procedure to start the NSD.
-
Change to the NSD home directory, such as:
C:\Inetpub\CSPGateway\nsd
-
Start the NSD with:
CSPnsd
The NSD starts as a Windows service (CSPnsdSv.exe). Once registered as a service, you can manage the NSD entirely through the Windows Service Manager.
-
Close down the NSD, by issuing the following command:
CSPnsd -stop
Alternatively, you can enter:
CSPnsd
This shows the status of the NSD’s Windows Service and allows you to perform one of the following actions:
-
Stop the NSD service if it is running.
-
Continue the NSD service if it is paused.
-
Remove the NSD service from the services database.
Alternatively, you can use the Windows Service Manager to manage the NSD. The NSD can be identified in the Service Manager by the description:
Cache Server Pages – Network Service Daemon
All errors are reported in the Web Gateway Event Log.
Other Startup Options
-
Display help information.
CSPnsd -h
-
Run the NSD interactively in a command window as opposed to as a Windows service. You must use this mode of operation if you are running multiple instances of the NSD.
CSPnsd -v
Starting NSD on Alternative TCP Port
By default, the NSD listens for incoming requests on TCP port 7038. You can override this by starting the service as follows:
CSPnsd –v [port_no]
Or:
CSPnsd –v -p[port_no]
- where port_no is the TCP port number of your choice.
On startup, the NSD creates the CSPnsd.ini file, which typically contains the following lines:
[SYSTEM]
Ip_Address=127.0.0.1
TCP_Port=7038
In this context, the clients are the Web Gateway modules contained within, or dynamically linked to, the web server and/or the CSP CGI modules invoked by the server. It is, therefore, essential that this file is not deleted or moved. It is also important that the web server processes can read this file. Set the privileges accordingly, bearing in mind the Windows user under which your web server is operating. The NSD clients attempt to find this file in a location contained within the Windows PATH variable (for example: C:\Windows). Consequently, the CSPnsd.ini file must be moved to this location before starting the web server.
It is inappropriate to store the NSD port number in the CSPnsd.ini file for the scenario in which multiple instances of the NSD are running. For Apache servers, there is a much better mechanism for communicating the TCP port number of the NSD to its clients. Specifically, set the following environment variables in the Apache configuration to indicate the address and port of the target NSD installation. The values specified in these environment variables take precedence over any values found in the CSPnsd.ini file:
-
CSP_NSD_NAME — This is the IP address of the NSD. Only use this parameter if the NSD is operating on a remote computer.
-
CSP_NSD_PORT — This is the TCP port of the NSD.
Example 1: Two Apache Virtual Hosts
Distribute the load for two Apache virtual hosts (say, 123.123.1.1 and 123.123.1.2) between two independent NSD installations (listening on TCP port 7038 and 7039).
Add the following directives to the Apache configuration (httpd.conf):
<VirtualHost 123.123.1.1>
ServerName 123.123.1.1
SetEnv CSP_NSD_PORT 7038
</VirtualHost>
<VirtualHost 123.123.1.2>
ServerName 123.123.1.2
SetEnv CSP_NSD_PORT 7039
</VirtualHost>
Example 2: Two Web Applications
Distribute the load for two web applications (say, /csp1 and /csp2) between two independent NSD installations (listening on TCP port 7038 and 7039).
-
Add the following directives to the Apache configuration (httpd.conf):
<Location /csp1> SetEnv CSP_NSD_PORT 7038 </Location> <Location /csp2> SetEnv CSP_NSD_PORT 7039 </Location>
-
Restart Apache after making changes to its configuration.
In cases where multiple instances of the NSD are running, it is recommended that the separate instances be installed in separate directories, each maintaining its own copies of the configuration file and the log file. The Web Gateway management pages for each instance can easily be accessed by using the NSD internal HTTP server. For example:
http://localhost:7038/csp/bin/Systems/Module.cxw
http://localhost:7039/csp/bin/Systems/Module.cxw