Creating, starting, and stopping servers

You can use the server script in the WebSphere® Liberty profile bin directory to create, start, stop, and check a server process. You can also run the serverManager shutdown command to stop a server, or isonline to determine whether a server is running.

About this task

The server management script in the <InstallDir>/runtime/wlp/bin directory contains the following useful actions:

  • create: Creates a server.
  • start: Starts the server as a background process.
  • stop: Stops a catalog or connectivity server.
  • status: Checks whether a specified server is running.
  • dump: Dumps diagnostic information from the server into an archive.
  • javadump: Dumps diagnostic information from the server JVM.

The server script uses the JAVA_HOME and JRE_HOME variables to find the java.exe file in your environment. Use server.env files at the installation and server levels to specify environment variables such as JAVA_HOME, WLP_USER_DIR, and WLP_OUTPUT_DIR.

A server requires a server.xml configuration file. This file describes the configuration of the server, either through direct assignment of values, or by including other configuration files. Bootstrap properties affect the configuration and initialization of the server. These properties can be specified through system properties or in a bootstrap.properties file in the server directory.

On Windows, enter the following commands to use the server script. The .bat extension is optional.

  • bin\server.bat create server_name --template=template_name
  • bin\server.bat start server_name
  • bin\server.bat stop server_name
  • bin\server.bat status server_name
  • bin\server.bat dump server_name
  • bin\server.bat javadump server_name

On Linux, enter the following commands to use the server script:

  • bin/server create server_name --template=template_name
  • bin/server start server_name
  • bin/server stop server_name
  • bin/server status server_name
  • bin/server dump server_name
  • bin/server javadump server_name

Where:

  • The server_name is the name of an existing server, or the name of the server you want to create. If a server name is not specified, defaultServer is used.
  • The template_name is the name of a server template. Templates are provided in the <InstallDir>/runtime/wlp/templates/servers directory for the following Insight Server types: cisDev, cisContainer, cisCatalog, cisInbound, cisOutbound.

    The single-server configuration (cisDev) is optimized for development with minimal configuration steps required to get the system up and running. In a cisDev server, both inbound and outbound connectivity are hosted, and HTTP inbound and outbound features are also enabled by default.

To stop and restart the servers in a multiple-server production environment, you must stop and shut down the servers in a specific order. See Maintaining operations in a production environment.

Important: Before you shut down a server in a multiple server environment, run the serverManager suspendBalancing command to suspend partition balancing. Do your start/stop/create activities for as many servers as required, and then run the serverManager resumeBalancing command to resume partition balancing.

If you intend to start a server immediately after you stop it, you must give the system time to balance all of the partitions. While the amount of time is not deterministic, around a minute is usually sufficient.

The stop command is used on a catalog or connectivity (cisInbound, cisOutbound) server.

Use the serverManager shutdown command from the <InstallDir>/runtime/ia/bin directory on a development server, or a runtime server instead of the Liberty server stop command. The shutdown command pauses and shutdowns server processes and components in the correct order, and ends pending processing and pauses components that are affected by the shutdown. For a runtime server, the command also communicates with the catalog server to check the status of WebSphere eXtreme Scale processes, then waits until those processes are finished before it shuts down the server.

Run the serverManager isonline command to determine which Liberty servers are active. Use this command to identify servers where you can deploy or activate solutions. You must provide administrator authentication credentials to run the script.

Procedure

  1. To determine whether a server is running, run the following command.
    • On Windows, run the serverManager isonline command as shown in the following example.
      serverManager isonline --host=localhost --port=9080 --username=user1 --password=user1 --trustStoreLocation=C:\IBM\ODMInsights88\runtime\wlp\usr\servers\cisDev\resources\security\key.jks --trustStorePassword=truststore
    • On Linux, run the serverManager isonline command as shown in the following example.
      ./serverManager isonline --host=localhost --port=9080 --username=user1 --password=user1 --trustStoreLocation=/opt/ibm/ODMInsights88/runtime/wlp/usr/servers/cisDev/resources/security/key.jks --trustStorePassword=truststore
  2. To stop a development or runtime server, run the following command.
    • On Windows, run the serverManager shutdown command as shown in the following example.
      serverManager shutdown --host=localhost --port=9080 --username=user1 --password=user1 --trustStoreLocation=C:\IBM\ODMInsights88\runtime\wlp\usr\servers\cisDev\resources\security\key.jks --trustStorePassword=truststore
    • On Linux, run the serverManager shutdown command as shown in the following example.
      ./serverManager shutdown --host=localhost --port=9080 --username=user1 --password=user1 --trustStoreLocation=/opt/ibm/ODMInsights88/runtime/wlp/usr/servers/cisDev/resources/security/key.jks --trustStorePassword=truststore

Results

By default, a server uses TCP/IP port 9080 for HTTP traffic, and port 9443 for HTTPS traffic. In some situations, the TCP/IP port is not released immediately when the server stops, and an error occurs when the server is restarted, for example: The port might already be in use.

Tip: Check your socket settings to see how long the kernel keeps a socket in the state FIN-WAIT-2. If tcp_fin_timeout is set to 60, for example, you must wait at least 60 seconds between stopping a server and restarting it.

Linux provides several administrative tools and utilities to help you manage your system:

  • cat /proc/sys/net/ipv4/tcp_fin_timeout: Returns the contents of a TCP variable named tcp_fin_timeout.
  • netstat -a | more: Lists all ports on your system.

To change the TCP timeout so that it persists across restarts, you can add the value to /etc/sysctl.conf. For example, set the timeout value to 10 seconds by running this command to modify the system control file:

sysctl -w net.ipv4.tcp_fin_timeout=10