Oracle GlassFish Server 3.0.1 Administration Guide

Configuring a Domain for Automatic Restart

This section provides instructions for configuring your system to automatically restart a domain .

The following topics are addressed here:

ProcedureTo Configure a Domain for Automatic Restart on Windows

On Windows, you can use the asadmin create-service subcommand to create a Windows service that restarts a Domain Administration Server (DAS).

  1. Create the service by using the create-service(1) subcommand.

  2. After the service is created, start the service by using the Windows Services Manager or the Windows Services Wrapper.

    For example, to start the service for the default domain by using the Windows Services Wrapper, type:


    C:\glassfishv3\glassfish\domains\domain1\bin\domain1Service.exe  start
    

Example 3–10 Creating a Service on a Windows System

This example creates a service for the default domain on a system that is running Windows.


asadmin> create-service
Found the Windows Service and successfully uninstalled it.
The Windows Service was created successfully.  It is ready to be started.  Here are 
the details:
ID of the service: domain1
Display Name of the service:domain1 GlassFish Server
Domain Directory: C:\glassfishv3\glassfish\domains\domain1
Configuration file for Windows Services Wrapper: C:\glassfishv3\glassfish\domains\
domain1\bin\domain1Service.xml
The service can be controlled using the Windows Services Manager or you can use the
Windows Services Wrapper instead:
Start Command:  C:\glassfishv3\glassfish\domains\domain1\bin\domain1Service.exe  start
Stop Command:   C:\glassfishv3\glassfish\domains\domain1\bin\domain1Service.exe  stop
Uninstall Command:  C:\glassfishv3\glassfish\domains\domain1\bin\domain1Service.exe
uninstall
Install Command:  C:\glassfishv3\glassfish\domains\domain1\bin\domain1Service.exe
install

This message is also available in a file named PlatformServices.log in the domain's 
root directory
Command create-service executed successfully.

ProcedureTo Configure a Domain for Automatic Restart on Oracle Solaris 10

On Oracle Solaris 10, you can use the asadmin create-service subcommand to create an Oracle Solaris Service Management Facility (SMF) service that restarts a DAS. The service grants to the process the privileges of the user that runs the process. When you create an SMF service, the default user is the superuser. If you require a different user to run the process, specify the user in method_credential.

If your process is to bind to a privileged port of Oracle Solaris 10, the process requires the net_privaddr privilege. The privileged ports of the Oracle Solaris operating system have port numbers less than 1024.

To determine if a user has the net_privaddr privilege, log in as that user and type the command ppriv -l | grep net_privaddr.

After you create and enable the SMF service, if the domain goes down, SMF restarts it.

Before You Begin

To run the asadmin create-service subcommand, you must have solaris.smf.* authorization. See the useradd and usermod man pages to find out how to set the authorizations. You must also have write permission in the directory tree: /var/svc/manifest/application/SUNWappserver. Usually, the superuser has both of these permissions. Additionally, Oracle Solaris 10 administration commands such as svccfg, svcs, and auths must be available in the PATH.

If a particular GlassFish Server domain should not have default user privileges, modify the manifest of the service and reimport the service.

  1. Create the service by using the create-service(1) subcommand.

  2. After the service is created, enable the service by using the svacdm enable command.

    For example:


    svacdm enable /appserver/domains/domain1
    

Example 3–11 Creating a Service to Restart a Domain Automatically on Oracle Solaris 10

This example creates a service for the default domain on a system that is running Oracle Solaris.


asadmin> create-service
The Service was created successfully. Here are the details:
Name of the service:application/GlassFish/domain1
Type of the service:Domain
Configuration location of the service:/home/gfuser/glassfish-installations
/glassfishv3/glassfish/domains
Manifest file location on the system:/var/svc/manifest/application
/GlassFish/domain1_home_gfuser_glassfish-installations_glassfishv3
_glassfish_domains/Domain-service-smf.xml.
You have created the service but you need to start it yourself.
Here are the most typical Solaris commands of interest:
* /usr/bin/svcs -a | grep domain1 // status
* /usr/sbin/svcadm enable domain1 // start
* /usr/sbin/svcadm disable domain1 // stop
* /usr/sbin/svccfg delete domain1 // uninstall
Command create-service executed successfully

See Also

As you administer your service, the following Oracle Solaris commands are useful: auths, smf_security, svcadm, svccfg, rbac, useradd, and usermod.

ProcedureTo Restart Automatically on Linux

To set up automatic restart on Linux, you edit the /etc/inittab file. If you use /etc/rc.local, or your system’s equivalent, place a line in /etc/rc.local that calls the desired asadmin subcommand.

  1. Add a line of text to the /etc/inittab file.

    For example:


    das:3:respawn:/opt/SUNWappserver/bin/asadmin start-domain --user admin 
    --passwordfile /opt/SUNWappserver/password.txt domain1

    The text must be on a single line. The first three letters are a unique designator for the process and can be altered.

ProcedureTo Prevent Service Shutdown When a User Logs Out on Windows

By default, the Java Virtual Machine (JVM) receives signals from Windows that indicate that Windows is shutting down, or that a user is logging out of Windows, which causes the system to shut itself down cleanly. This behavior causes the GlassFish Server service to shut down. To prevent the service from shutting down when a user logs out, you must set the -Xrs Java VM option.

  1. Add the following line to the section of the as-install\domains\domain-name\config\domain.xml file that defines Java VM options:

    <jvm-options>-Xrs</jvm-options>
  2. If the GlassFish Server service is running, restart the service for your changes to take effect.