bea.com | products | dev2dev | support | askBEA |
![]() |
![]() |
|
![]() |
e-docs > WebLogic Server > Configuring and Managing WebLogic Server > Setting Up a WebLogic Server Instance as a Windows Service |
Configuring and Managing WebLogic Server
|
Setting Up a WebLogic Server Instance as a Windows Service
If you want a WebLogic Server to start automatically when you boot a Windows host, you can set up the server as a Windows service.
For each server that you set up as a Windows service, WebLogic Server creates a key in the Windows Registry under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services. The registry entry contains such information as the name of the server and other startup arguments. When you start the Windows host, it passes the information in the registry to the JVM.
The following tasks describe setting up servers as Windows services:
WebLogic Server includes a master script, WL_HOME\server\bin\installSvc.cmd, that you can use to set up a server instance as a Windows Service. Instead of invoking the installSvc.cmd master script directly, create your own script that supplies values for a set of variables and then calls the installSvc.cmd script:
Listing 5-1 Script for Setting Up a Server as a Windows Service
@rem *************************************************************************
@rem This script sets up a WebLogic Server instance as a Windows service.
@rem It sets variables to specify the domain name, server name, and optionally,
@rem user credentials, startup mode, and arguments for the JVM. Then the script
@rem calls the %WL_HOME%\server\bin\installSvc.cmd script.
@rem *************************************************************************
echo off
SETLOCAL
@rem Set DOMAIN_NAME to the name of the domain in which you have defined
@rem the server instance.
set DOMAIN_NAME=myWLSdomain
@rem Set USERDOMAIN_HOME to the root directory of the domain's Administration
@rem Server, which is the directory that contains the domain's config.xml file.
@rem For more information about the root directories for servers, refer to
@rem A Server's Root Directory.
set USERDOMAIN_HOME=D:\bea\user_projects\myWLSdomain
@rem Set SERVER_NAME to the name of the existing server instance that you want
@rem set up as a Windows service.
set SERVER_NAME=myWLSserver
@rem Optional: one way of bypassing the username and password prompt during
@rem server startup is to set WLS_USER to your system username and WLS_PW to
@rem your password. The script encrypts the login credentials and stores them
@rem in the Windows registry.
@rem The disadvantage to this method is that changing the username or password
@rem for the server instance requires you to delete the Windows service and set
@rem up a new one with the new username and password.
@rem If you use a boot identity file to bypass the prompt, you can change the
@rem login credentials without needing to modify the Windows service. For more
@rem information about bypassing the username and password prompt, refer to
@rem "Bypassing the Prompt for Username and Password" in the Administration
@rem Console Online Help.
set WLS_USER=
set WLS_PW=
@rem Optional: set Production Mode. When STARTMODE is set to true, the server
@rem starts in Production Mode. When not specified, or when set to false, the
@rem server starts in Development Mode. For more information about
@rem Development Mode and Production Mode, refer to
@rem "Starting in Development Mode or Production Mode" in the Administration
@rem Console Online Help.
set STARTMODE=
@rem Set JAVA_OPTIONS to the Java arguments you want to pass to the JVM. Separate
@rem multiple arguments with a space.
@rem If you are using this script to set up a Managed Server as a Windows service,
@rem you must include the -Dweblogic.management.server argument, which
@rem specifies the host name and listen port for the domain's Administration
@rem Server. For example:
@rem set JAVA_OPTIONS=-Dweblogic.management.server=http://adminserver:7501
@rem For more information, refer to
@rem "weblogic.Server Configuration Options" in the WebLogic Server Command
@rem Reference.
set JAVA_OPTIONS=
@rem Optional: set JAVA_VM to the java virtual machine you want to run.
@rem For example:
@rem set JAVA_VM=-server
set JAVA_VM=
@rem Set MEM_ARGS to the memory args you want to pass to java. For example:
@rem set MEM_ARGS=-Xms32m -Xmx200m
set MEM_ARGS=
@rem Call Weblogic Server service installation script. Replace <WL_HOME> with
@rem the absolute pathname of the directory in which you installed WebLogic
@rem Server. For example:
@rem call "D:\bea\weblogic810\server\bin\installSvc.cmd"
call "<WL_HOME>\server\bin\installSvc.cmd"
ENDLOCAL
The -delay argument is optional, but recommended to make sure that an Administration Server has time to complete its startup cycle before any Managed Servers start.
For example, the modified beasvc invocation will resemble the following:
"%WL_HOME%\server\bin\beasvc" -install
-svcname:"beasvc %DOMAIN_NAME%_%SERVER_NAME%"
-depend: "beasvc myDomain_myAdminServer"
-delay: "800"
-javahome:"%JAVA_HOME%" -execdir:"%USERDOMAIN_HOME%"
-extrapath:"%WL_HOME%\server\bin" -password:"%WLS_PW%"
-cmdline:%CMDLINE%
Note: If you use the Domain Configuration Wizard to create a domain and server, some of the domain templates prompt you to set up the server as a Windows service. You can choose yes to set up an Administration Server as a Windows service. However, if you want to set up a Managed Server with a dependency, you must choose no in the wizard and complete the steps in this section. Regardless of whether you choose yes or no, if the domain template includes a prompt for setting up a service, it will create a script named installService.cmd in the server's root directory, which is similar to the script in Listing 5-1.
Using a Non-Default JVM with a Windows Service
If you are not using the JVM installed with WebLogic Server, you must edit the master script so that it installs server instances that use a non-default JVM:
To verify that you successfully set up a WebLogic Server as a Windows service, do the following:
If your setup was successful, the beasvc -debug command starts your server. If the script returns an error similar to the following, make sure that you specified the correct service name:
Unable to open Registry Key ....... System\CurrentControlSet\Services\beasvc example_examplesServer\Parameters
Using the Control Panel to Stop or Restart the Service
After you set up a server to run as a Windows service, you can use the Service Control Panel to stop and restart the server:
Removing a Server as a Windows Service
To remove a server as a Windows service, do the following:
Listing 5-2 Script to Remove a Windows Service
@rem *************************************************************************
@rem This script is used to uninstall a WebLogic Server service for a
@rem server instance that is defined for the current domain.
@rem The script simply sets the DOMAIN_NAME and SERVER_NAME variables and calls
@rem the %WL_HOME%\server\bin\uninstallSvc.cmd script.
@rem *************************************************************************
echo off
SETLOCAL
@rem Set DOMAIN_NAME to the name of the domain that contains the server.
set DOMAIN_NAME=myWLSdomain
@rem Set SERVER_NAME to the name of the server that you want to remove as
@rem a service.
set SERVER_NAME=myWLSserver
@rem Call Weblogic Server service uninstallation script. Replace <WL_HOME> with
@rem the absolute pathname of the directory in which you installed WebLogic
@rem Server. For example:
@rem call "D:\bea\weblogic810\server\bin\uninstallSvc.cmd"
call "<WL_HOME>\server\bin\uninstallSvc.cmd"
ENDLOCAL
If the removal script runs successfully, its output in the command window includes a line similar to the following:
beasvc mydomain_myserver removed.
Changing Startup Credentials for a Server Set Up as a Windows Service
To change passwords or add users for any WebLogic Server, you must start the server and use the security realm's administration tools. If you use the security realm that is installed with WebLogic Server, you can use the Administration Console. If you use a third-party security realm, you must use the administration tools provided in that realm.
After you change the security data, you must do the following to change the arguments that are passed to the server during the startup cycle:
After you run the script, you can remove the password from this file.
Viewing Messages for a Server Set Up as a Windows Service
All WebLogic Server instances maintain log files, which you can view through the Administration Console. By default, the log files are located on server's host computer. For information about viewing log messages, refer to "Viewing Server Logs" in the Administration Console Online Help.
In addition to writing messages to a log file, server instances print a subset of those messages to standard out. The JVM that runs the server also can print its own set of messages to the server's standard out. By default, if you start a server as a Windows service, you cannot view the server's standard out or standard error. For more information about messages that are sent to standard out and standard error, refer to "Specifying Which Messages a Server Sends to Standard Out" in the Administration Console Online Help.
To redirect a standard out to a file for a server that is set up as a Windows service:
@rem Set JAVA_OPTIONS to the java flags you want to pass to the vm. i.e.:
@rem set JAVA_OPTIONS=-Dweblogic.attribute=value -Djava.attribute=value
set JAVA_OPTIONS= -Dweblogic.Stdout="c:\myDomain\stdout.txt" -Dweblogic.Stderr="c:\myDomain\stdout.txt"
The WebLogic Server Windows Service Program (beasvc.exe)
The installSvc.cmd and uninstallSvc.cmd master scripts are convenience wrappers for the WebLogic Server Windows Service program, beasvc.exe. You can modify those scripts or create your own scripts that invoke beasvc.exe and install WebLogic Servers or Node Managers as Windows services. If you want to uninstall a service, you can invoke beasvc.exe directly without creating a script.
For information on how to install or remove the Node Manager as a Windows service, see "Starting Node Manager as a Windows Service" in the Configuring and Managing WebLogic Serve guide.
beasvc.exe is located in WL_HOME\server\bin and your script can pass any of the following parameters:
Win32 systems have a 2K limitation on the length of the command line. If the classpath setting for the Windows service startup is very long, the 2K limitation could be exceeded. To work around this limitation, you can do the following when using the beasvc command:
![]() |
![]() |
![]() |
![]() |
||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |