NexJ Logo

Registering Model Server as a service

If desired, you can register NexJ Model Server as a service on Windows or Linux.

You can register Model Server as service on Windows using the modeld-svc batch file. On Linux, you can register Model Server as a service using the modeld.service configuration file, which leverages the systemctl interface.

Only users with administrative privileges can register and unregister Model Server as a service.

Registering Model Server as a service on Windows

You can register Model Server as a Windows service.

To register Model Server as a Windows Service:

  1. Open a Command Prompt window using the Run As Administrator option.
  2. From the <SERVER_HOME>/bin directory, run the following command:
    modeld-svc.bat -i [-dsmj] [-X] [-D] [<Model Server options>]

    You can use the modeld-svc.bat -? command to view all Model Server options.

    where:

    -i
    Indicates you want to register Model Server as a Windows service.

    -d <number>
    Enables remote debugging on the specified port number, for example, -d 7777.

    -s
    Suspends JVM until a debugger connects. Ignored unless -d is also specified.

    -m <number>
    Sets the heap size, for example, -m 1024M or -m 1G.

    -j <name>
    Loads JVM arguments from the specified custom file specified instead of loading them from jvm.conf.

    -X<argument>
    Specifies additional JVM options that can be passed to the JVM to overwrite batch file defaults. For example, use -Xss4096k to change the default thread stack size.

    -D<property>
    Specifies properties to pass through to the application. For example, use -Dnexj.ajp.port=8509 to set the AJP port to 8509.

    The following Model Server options are supported in the command:

    Info

    Model Server options require a space between the option and option value. JVM options do not require a space. Additionally, values that contain a space must be enclosed in quotation marks.

    -c <url>
    Path to the node configuration file, for example, -c <SERVER_HOME>\modeld.conf.

    -n <name>
    Node name, for example, -n node1.

    -o <number>
    Port offset number, for example, -o 100.

    -l <dir>
    Path to the log file directory, for example, -l <SERVER_HOME>\log.

    -C <url>
    Path to the environment file, for example, -C <SERVER_HOME>\workspace\env\envFile.environment.

    -P <url>
    Path to the environment properties file, for example, -P <SERVER_HOME>\workspace\env\propertiesFile.properties. If you want to issue the -P command, ensure that an environment file exists and has been specified using the -C command.

    -M <url>
    Path to the metadata directory, for example, -M <SERVER_HOME>\workspace\meta.

You have registered Model Server as a Windows service.

You can start the Services Microsoft Management Console (MMC) to verify that Model Server is registered as a service.

Registering Model Server as a service on Linux

You can register Model Server by specifying the server location in the modeld.service configuration file, copying the configuration file to the appropriate location, and running a command to register the server as a service.

The modeld.service configuration file contains the default arguments required for running Model Server as a Linux service. Before running the service, you can edit the modeld.service configuration file to add any required JVM arguments and parameters.

To register Model Server as a service:

  1. Navigate to <SERVER_HOME>/bin.
  2. Open the modeld.service file in a text editor.
  3. Modify the Environment=MODELD_HOME variable to point to <SERVER_HOME> directory. For example, change the variable to Environment=MODELD_HOME=/opt/nexj/modeld.
  4. Save and close the modeld.service file.
  5. Copy the modeld.service file to /etc/systemd/system/.
  6. From the terminal, run the following command to register the server as a service:
    systemctl enable modeld

    Info

    You can use the following command to disable the server as a service:
    systemctl disable modeld

  7. Use the following command to start the service:
    systemctl start modeld

    Info

    You can use the following command to stop the service:
    systemctl stop modeld

You have registered Model Server as a service.

Unregistering Model Server as a service

To unregister Model Server as a service:

  • On Windows, run the following command from the <SERVER_HOME>/bin directory:
    modeld-svc.bat -u [-s]
    where -u indicates that you want to uninstall Model Server as a Windows service and -s specifies the name provided when the server was registered as a Windows service.
  • On Linux, delete the service file from /etc/systemd/system/ and run the systemctl daemon-reload command from the terminal.