Sun GlassFish Enterprise Server v3 Administration Guide

Automatically Restarting a Domain

This section provides instructions for configuring your system to automatically restart the domain on Solaris.

The following topics are addressed here:

ProcedureTo Automatically Restart a Domain on Solaris 10

The create-service subcommand is supported on the Solaris and Windows platforms, however, only Solaris instructions are provided here.

On Solaris 10, you can use the asadmin create-service subcommand to create a Solaris Service Management Facility (SMF) service that restarts a Domain Administration Server (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 Solaris 10, the process requires the net_privaddr privilege. The privileged ports of the 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, the Solaris 10 administration commands such as svccfg, svcs, and auths must be available in the PATH.

If a particular Enterprise 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.

    Information about properties for the subcommand is included in this help page.

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

    For example:


    svacdm enable /appserver/domains/domain1
    

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

This example creates a service .


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 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 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 Enterprise 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 Enterprise Server service is running, restart the service for your changes to take affect.