For Windows platforms

Starting and stopping a Liberty server as a Windows service

You can optionally register the Liberty server as a Microsoft Windows Service program when you run on Windows operating systems. You can manually start, stop, and unregister the Liberty server as a Windows service. You can also use the Microsoft Windows Services program to change Liberty to start automatically as a Windows service when the Windows server starts.

Before you begin

Set the JAVA_HOME environment variable before you run the following commands. You can use the server.env file path to set the JAVA_HOME value reliably. For more information about using the server.env file, see Customizing the Liberty environment.

About this task

The commands to register, start, stop, and unregister Liberty as a Windows service use the same server.bat file that is used when you start the Liberty server from the command line. For available values of [options], see Server command options.

Procedure

  • Use the following command to register the server:
    server registerWinService serverName 
    where serverName is the name of the server.
    The Windows service name and Windows service display name is the serverName. After you register, you can find and administer the Liberty server as a service by using regedit from the Windows Registry program. Entries for the service in the registry are in the following locations:
    HKEY_LOCAL_MACHINE->SOFTWARE->Wow6432Node->Apache Software Foundation->Procrun 2.0->serverName
    HKEY_LOCAL_MACHINE->SYSTEM->CurrentControlSet->services->serverName
  • Use the following command to start the server:
    server startWinService serverName [options]
    where serverName is the name of the server.
  • Use the following command to stop the server:
    server stopWinService serverName
    where serverName is the name of the server.
  • Use the following command to unregister the server:
    server unregisterWinService serverName
    where serverName is the name of the server.

What to do next

When you install a fix pack by using archives, the directory under which the fix pack is installed can change from the directory where the Liberty server was running before you installed the fix pack. If you are running a Liberty server as a Windows service, then unregister that Liberty server as a Windows service before you install the fix pack. After you install the fix pack, register the Liberty server as a Windows service again.

If you need to manually remove Liberty as a Windows service, then update the Windows registry by using the Windows regedit program. The two entries that need to be removed from the Windows Registry are in the following locations:
HKEY_LOCAL_MACHINE->SOFTWARE->Wow6432Node->Apache Software Foundation->Procrun 2.0->serverName
HKEY_LOCAL_MACHINE->SYSTEM->CurrentControlSet->services->serverName