Deploying Model Server
You can deploy NexJ Model Server to a locally addressable location (somewhere on the network) or to a remote location. You can either use NexJ Studio or the command line to deploy.
When you deploy Model Server , a file is created for each node in the SERVER_HOME
directory. The file specifies the node name . By default, nodes are named node=<node1>, node=<node2>, ..., node=<nodeN>
for deployments to multiple locations. You can change a node's value if you want to give the node a meaningful name, for example, report_server
. Nodes require a unique name. For more information about NexJ-specific system properties, see Specifying JVM arguments and system properties .
Before you deploy Model Server, you must install any prerequisites as mentioned in Preparing the host machine.
Deploying through NexJ Studio
Use these steps to deploy through NexJ Studio using only an environment file to specify the relevant values. If you want to use environment variables from a properties file, follow the instructions in Specifying environment properties through a properties file.
To deploy Model Server using NexJ Studio:
- In NexJ Studio, in the Deployment layer's Environment tab, open the environment file for the current deployment.
- In the Overview tab, ensure that Type is set to Generic.
In the Deployment Location field, specify the folder directories or SSH folder directories for all the server nodes. For example, to deploy to two Model Server nodes, specify the directories as follows:
Operating System Nodes Servers Remote/local deployment Example Windows 2 2 Remote \\hostname1\nexj\modeld,\\hostname2\nexj\modeld
2 1 Remote \\hostname\nexj\modeld\{node1,node2}
or\\hostname\nexj\modeld\node1,\\hostname\nexj\modeld\node2
2 1 Local D:\nexj\modeld\node1,D:\nexj\modeld\node2
orD:\nexj\modeld\{node1,node2}
Linux 2 2 Remote ssh://hostname1/opt/nexj/modeld,ssh://hostname2/opt/nexj/modeld
2 1 Remote ssh://hostname/opt/nexj/modeld/{node1,node2}
orssh://hostname/opt/nexj/modeld/node1,ssh://hostname/opt/nexj/modeld/node2
2 1 Local /opt/nexj/modeld/node1,/opt/nexj/model/node2
or/opt/nexj/modeld/{node1,node2}
When running two or more nodes on the same server, ensure the port.offset property is specified so ports from different nodes do not conflict with each other. The default offset for the port is relative to the port in the HTTP server URL. For example, if the HTTP server URL is http://host.domain.ext:7080/nexj and the port offset is 100, the JVM will listen to port 7180 for HTTPS traffic.
For more information about specifying system properties, see Specifying JVM arguments and system properties.
- If you are deploying a Model Server cluster, on the Clustering/Session tab, select the Distributed (Enable Clustering) checkbox.
- Save the updated environment file.
- If using SSH, do the following:
- Click . The Preferences dialog opens.
- Click .
- In the Known hosts file field, enter the path to the known hosts file. The known hosts file allows NexJ Studio to authenticate the server.
- In the Personal key field, do one of the following:
- If basic authentication is enabled in the environment file, select the Use password from the .server file (basic authentication) .
- If basic authentication is not enabled in the environment file, in the Identity file field, enter the path to the private key for the client.
- Copy the appropriate database driver, such as
jtds-1.2.2-9.jar
orojdbc14.jar
, to your project'slib
directory. Click the Deploy Model button . The server instance or cluster is installed in the directories that you specified.
In case the database driver that you copied in the previous step does not get deployed, be sure to copy the appropriate database driver, such as
jtds-1.2.2-9.jar
orojdbc14.jar
, to the<
SERVER_HOME>\jvm
directory for each deploy location that you specified earlier in the Deployment Location field. If you are using Java 8 or lower, you can, alternatively, add the database driver to the$JAVA_HOME/jre/lib/ext
folder . If using SSH, tools such as sftp or scp may be required to copy the database driver. For more information about required database drivers, see Required database drivers in the NexJ CRM Release Notes.
The Model Server instance or cluster is deployed, and a BUILD SUCCESSFUL message displays in the Console.
The deploy
directory contains the following directories:
Directory | Contains |
---|---|
bin | modeld.bat, modeld-svc.bat, modeld.sh files |
conf | jvm.conf, log4j.properties, modeld.conf files |
data/<node> | Persistent data in <node> |
jvm | Framework JAR files |
log | Log outputs |
model | Model JAR files |
tmp | Temporary working files |
win32-x64 | 64-bit executable file |
win32-x86 | 32-bit executable file |
Deploying using command line
Use these steps to deploy through the command line using only an environment file to specify the relevant values. If you want to use environment variables from a properties file, follow the instructions in Specifying environment properties through a properties file.
You may also use the command line to deploy Model Server without the help of NexJ Studio. The command line is necessary if you cannot use NexJ Studio in the deployment environment, or if you require the deployment process to be automated with a script.
You need the following to use this method:
- Apache Ant
- Java Development Kit
- Studio plugin folder (nexjstudio_version)
- Published model file
Specify the location for these items in the command line. For the Studio plugin folder, either NexJ Studio should be installed or the plugin should be extracted on the hard drive. If NexJ Studio is installed, the plugin folder is located in the NEXJ_PLUGIN/version/plugins
directory.
To deploy Model Server using the command line:
The Model Server instance or cluster is deployed, and a BUILD SUCCESSFUL message displays in the Console.
If you want to compile the code using JDK 11, before starting the server, you will need to set the java code executable in the build.properties
file to Java 11, as shown in the following example:
javac.executable=C:/Java/jdk-11.0.2/bin/javac.exe
Specifying environment properties through a properties file
You can use a properties file to set your environment properties through variables. This removes the need to edit the environment file directly every time you modify a setting and is useful if you want to experiment with the property values. For example, to use a different HTTP URL for unit testing and staging from that you use in production, you can create three separate properties files named development.properties
, unittest.properties
, and staging.properties,
specify a different value for the httpURL property in each of these files, and set them all for use with the same environment file.
In case of a conflict, properties specified through the jvm.conf
and modeld.conf
files override the top-level variables in the environment file. For more information about jvm.conf
and modeld.conf
, see Specifying JVM arguments and system properties .
To use a property file for a Model Server deployment:
Create properties files as needed.
You can create a properties file by creating a text file in your project folder and changing its extension to
.properties
or by opening the environment in the Deployment layer of NexJ Studio and selecting Add in drop-down on the top right corner of the environment overview.- Specify property values in the property files in the following format:
<propertyName>=<propertyValue>
For example,
callRecordsEnabled=true
orcloneCount=1
. - Select the properties file you want to use for the deployment:
- If using NexJ Studio, select the file from the Set current server dropdown.
- If using the command line, specify the property file using the following command:
-Dserver.properties=$<PROP_FILE> \
wherePROP_FILE
staging.properties
.
- In the environment file, specify the property that needs to be pulled from the properties file in the following format:
<propertyName>="${<propertyName2>}"
wherepropertyName
is the property name as mentioned in the environment file, andpropertyName2
is the name of the property in the properties file that should replacepropertyName
. For example,callRecordSetting="${callRecordsEnabled}"
. When you deploy,callRecordsEnabled
is replaced bytrue
based on the setting in the properties file. - In the properties file, specify the environment file in the following format:
config=<environmentFileName>.environment
For example, specifyconfig=development.environment
. Click the Deploy Model button in NexJ Studio or issue the deployment command using the command line. The following is a sample command that uses a properties file:
TEXTc:\apache-ant\bin\ant -propertyfile "c:/work/core_deploy.properties" -f "c:/work/plugins/com.nexjsystems.nexjstudio/build/build.xml" server.config server.deploy
The server gets deployed with the mapped values from the selected properties file.