Skip navigation.
Downloads | Product Documentation | Support

WebLogic Server Partners' Guide

# Creating Startup Scripts

WebLogic Server provides several techniques for starting server instances and clusters, all of which can be encapsulated in startup scripts that you install along with your configuration template. The following sections provide an overview of the techniques:

- Choosing a Startup Technique
- Using WebLogic Server Start Scripts
- Creating Scripts that Invoke Node Managers
- Creating Windows Services for Instances of WebLogic Server
- Installing Your Startup Scripts

# Choosing a Startup Technique

The technique that you use to start an embedded server depends on the complexity of the WebLogic Server domain that you install, the number of computers that host server instances within the domain, and the underlying operating system. Table 3-1 compares the various techniques.

Table 3-1 Startup Techniques

This Technique... | Is Recommended When...
--- | ---
Using WebLogic Server start scripts | Your WebLogic Server domain runs on a single WebLogic Server host. A WebLogic Server host is a computer on which you have installed the WebLogic Server software. A WebLogic Server domain is a self-contained administrative unit that contains servers, applications, and other resources such as database connection pools. In the simplest configuration of a WebLogic Server domain, all applications run on a single server instance on a single WebLogic Server host. With this simple configuration, invoking the startup scripts that WebLogic Server provides is the easiest technique for starting a server. The scripts configure an environment and start a server instance on the current WebLogic Server host. You must log on to a WebLogic Server host (either directly or by opening a shell in a remote session) to invoke these scripts. For more information, see Using WebLogic Server Start Scripts.
Creating scripts that invoke a Node Manager | Your WebLogic Server domain includes multiple server instances and you want these server instances to run on multiple WebLogic Server hosts. Such a domain can include clusters, which provide scalability and failover capabilities. Each WebLogic Server host can run a Node Manager, which is a Java utility that can start and stop Managed Server instances on the current WebLogic Server host. Because a Node Manager can receive startup and shutdown requests from remote WebLogic Server hosts, you can create one script that invokes Node Managers running on multiple WebLogic Server hosts to start all server instances in a distributed cluster or a domain. For more information, see Creating Scripts that Invoke Node Managers.
Installing a server as a Windows service | Your domain runs on a platform that includes the Microsoft Windows operating system. The Windows operating system can automatically start Windows services as part of the computer's boot up process. On a single WebLogic Server host, you can configure dependencies so that a Managed Server starts only after an Administration Server starts. However, you cannot configure a dependency between Windows services that run on different computers. For more information, see Creating Windows Services for Instances of WebLogic Server.

# Using WebLogic Server Start Scripts

WebLogic Server provides a layered set of scripts that set environment variables and configure a Java command. The Java command invokes the `weblogic.Server` class, which is the main class for a server instance.

When you install the WebLogic Server software, the installation includes the `WL_HOME\common\bin\commEnv.sh` (and `commEnv.cmd` on Windows) script. This script sets environment variables that define defaults for all WebLogic software on the current host. It defines the following:

- The BEA home directory, which contains licensing information for BEA software.
- The home of the Java SDK that the Node Manager and WebLogic Server instances use.
- The Java classpath that the Node Manager and WebLogic Server software requires. If you need to add classes to the WebLogic Server classpath, add them to the `WEBLOGIC_CLASSPATH` variable in this script.
- Java options that configure basic attributes of the Java Virtual Machines (JVMs) that run instances of WebLogic Server, the Node Manager, and WebLogic Server utilities on this host. For example, for some JVMs, the options configure the heap size and whether the JVM uses Just In Time (JIT) compiling.

For each domain that you create based on a domain configuration template that BEA provides, the Configuration Wizard places startup scripts in the domain directory. These scripts do the following:

- Invoke the `commEnv.sh` (and `commEnv.cmd` on Windows) script.

The domain-specific startup scripts can override the values that the `commEnv` script sets for some of the variables.

- Set additional JVM parameters that are specific to running instances of WebLogic Server.
- Invoke the `weblogic.Server` class.

Your own templates can include the WebLogic Server scripts or similar startup scripts that you create.

The Configuration Wizard is a Java application that you use to create and configure domains. The Configuration Wizard prompts you to choose a domain configuration template to provide the basic structure for a domain.

For example, if you create a domain based on the Basic WebLogic Server Domain template, and if you accept all default values, the Configuration Wizard creates the following scripts in `BEA_HOME\user_projects\domains\mydomain`, where `BEA_HOME` is the BEA home directory:

- `startWebLogic.sh` (and `startWebLogic.cmd` on Windows), which starts Administration Server. The script calls the `commEnv` and `VMOptions` scripts to set environment variables. Then it sets values of domain-specific variables and invokes the `weblogic.Admin` class. You can configure this script to override some or all of the values that the `commEnv` and `VMOptions` scripts set.
- `startManagedWebLogic.sh` (and `startManagedWebLogic.cmd` on Windows), which starts Managed Servers. You can use this one script to start multiple Managed Servers by passing parameters when you invoke the script, or you can configure this script to start a single Managed Server. For more information, refer to "Starting Managed Servers From a WebLogic Server Script" in the Administration Console Help.

# Creating Scripts that Invoke Node Managers

Each WebLogic Server host can run a Node Manager, which can start Managed Server instances on the current host. The Node Manager cannot start an Administration Server.

To create and use a script that uses Node Managers to start Managed Servers:

1. Make sure that the Node Manager is active on each WebLogic Server host.

On a Windows computer, you can configure the WebLogic Server silent installer to install the Node Manager as a Windows Service. On a UNIX computer, your customers can configure the Node Manager to run as a daemon.

For more information, see in "Configuring, Starting, and Stopping Node Manager" Configuring and Managing WebLogic Server.

2. Start the Administration Server by doing any of the following:

- Calling the `startWebLogic.sh` script that the Configuration Wizard creates.
- Calling a script that you create.
- Installing the Administration Server as a Windows Service or a UNIX daemon. See Creating Windows Services for Instances of WebLogic Server.

You cannot use a Node Manager to start the Administration Server.

3. For each Managed Server in the domain, indicate which computer (machine) you want to host the Managed Server. See "Configuring a Machine" in the Administration Console Online Help.
4. Create a script that does the following:

1. Invokes `WL_HOME/common/bin/commEnv.sh` (or `commEnv.cmd` on Windows). This script sets environment variables that the `weblogic.Admin` utility requires.
2. Invokes the `java weblogic.Admin START` or `STARTINSTANDBY` command for each server instance in the domain. If your domain includes a cluster, your script can invoke the `java weblogic.Admin STARTCLUSTER` command.

For more information, refer to "weblogic.Admin Command-Line Reference" in the WebLogic Server Command Line Reference.

5. From a single WebLogic Server host, run the script that you created in the previous step.

The `weblogic.Admin` utility connects to the Administration Server, which causes the Node Manager to start the specified Managed Servers on the machines that you specified in step 3.

# Creating Windows Services for Instances of WebLogic Server

If you want WebLogic Server instances within your domain to start automatically when you boot a Windows host computer, you can create a script that causes a WebLogic Server instance to run as a Windows service. The script must invoke the WebLogic Server `beasvc` utility, which 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.

Neither the WebLogic Server installation program nor the Configuration Wizard can configure servers as Windows services when run in silent mode. Instead, you create a script that invokes the WebLogic Server `beasvc` utility.

If you want to install a Managed Server as a Windows service, your script should include a Java option that specifies how the Managed Server connects to the Administration Server.

If you want to install an Administration Server and one or more Managed Servers as Windows services on the same WebLogic Server host, your script should include a Java option that specifies how the Managed Server connects to the Administration Server and a `beasvc` option that configures dependencies between the Windows services. The Administration Server must complete its startup cycle before any Managed Servers start.

For more information, refer to "Setting Up a WebLogic Server Instance as a Windows Service" in Configuring and Managing WebLogic Server.

# Installing Your Startup Scripts

To install your startup scripts along with your application and WebLogic Server software:

1. Use the Template Builder to create a domain configuration template. See "Creating Configuration Templates Using the Template Builder" in the Creating WebLogic Configurations Using the Configuration Wizard guide.
2. Include your start scripts as part of the configuration template. On the Windows platform, you can also include your start script as an item on the Windows Start menu.
3. Configure the Configuration Wizard to run in silent mode and install your domain configuration template. See "Starting in Silent Mode" in Creating WebLogic Configurations Using the Configuration Wizard.