On Windows systems, the create-service
subcommand creates a Windows
service to represent the DAS or instance. The service is created in the
disabled state. After this subcommand creates the service, you must use
the Windows Services Manager or the Windows Services Wrapper to start,
stop, uninstall, or install the service. To administer the service from
the Windows command line, use the sc.exe
tool.
This subcommand must be run as the OS-level administrator user.
-
Create the service by using the create-service
subcommand.
-
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
sc.exe
tool, type:
If you are using the sc.exe
tool to administer the service, use the
tool as follows:
* To obtain information about the service, use the sc query
command.
* To stop the service, use the sc stop
command.
* To uninstall the service, use the sc delete
command.
Example 3-10 Creating a Service to Restart a DAS Automatically on
Windows
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.
Example 3-11 Querying the Service to Restart a DAS Automatically on
Windows
This obtains information about the service for the default domain on a
system that is running Windows.
C:\> sc query domain1
SERVICE_NAME: domain1
TYPE : 10 WIN32_OWN_PROCESS
STATE : 1 STOPPED
WIN32_EXIT_CODE : 1077 (0x435)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0
On Linux systems, the create-service
subcommand creates a
System-V-style initialization script
/etc/init.d/GlassFish_`domain-or-instance-name and installs a link to
this script in any `/etc/rc`N
.d` directory that is present, where N is
0
, 1
, 2
, 3
, 4
, 5
, 6
, and S
. After this subcommand
creates the script, you must use this script to start, stop, or restart
the domain or instance.
The script automatically restarts the domain or instance only during a
reboot. If the domain or instance is stopped, but the host remains
running, the domain or instance is not restarted automatically. To
restart the domain or instance, you must run the script manually.
You might no longer require the domain or instance to be automatically
restarted during a reboot. In this situation, use the operating system
to delete the initialization script and the link to the script that the
create-service
subcommand creates.
The create-service
subcommand must be run as the OS-level root user.
Example 3-12 Creating a Service to Restart a DAS Automatically on Linux
This example creates a service for the default domain on a system that
is running Linux.
asadmin> create-service
Found the Linux Service and successfully uninstalled it.
The Service was created successfully. Here are the details:
Name of the service:domain1
Type of the service:Domain
Configuration location of the service:/etc/init.d/GlassFish_domain1
User account that will run the service: root
You have created the service but you need to start it yourself.
Here are the most typical Linux commands of interest:
* /etc/init.d/GlassFish_domain1 start
* /etc/init.d/GlassFish_domain1 stop
* /etc/init.d/GlassFish_domain1 restart
For your convenience this message has also been saved to this file:
/export/glassfish3/glassfish/domains/domain1/PlatformServices.log
Command create-service executed successfully.
To Configure a DAS or an Instance for Automatic Restart on Oracle
Solaris
^^^^^^^^^^^^^^^^^^^^^^^^^
On Oracle Solaris systems, the create-service
subcommand creates an
Oracle Solaris Service Management Facility (SMF) service that restarts a
DAS or an instance. 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, 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 or instance
is stopped, SMF restarts it.
To run the create-service
subcommand, you must have solaris.smf.*
authorization. For information about how to set the authorizations, see
the
useradd
(1M)
man page and the
usermod
(1M)
man page. 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
administration commands such as
svccfg
,
svcs
,
and
auths
must be available in the PATH.
If a particular GlassFish Server domain or instance should not have
default user privileges, modify the manifest of the service and reimport
the service.
-
Create the service by using the create-service
subcommand.
-
After the service is created, enable the service by using the
svacdm enable
command.
For example, to enable the SMF service for the default domain, type:
svacdm enable /appserver/domains/domain1
Example 3-13 Creating a Service to Restart a Domain Automatically on
Oracle Solaris
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
For information about administering the service, see the following
Oracle Solaris documentation:
-
"http://www.oracle.com/pls/topic/lookup?ctx=E18752&id=SYSADV1hbrunlevels-25516[Managing
Services (Overview)]" in System Administration Guide: Basic
Administration
-
"http://www.oracle.com/pls/topic/lookup?ctx=E18752&id=SYSADV1faauf[Managing
Services (Tasks)]" in System Administration Guide: Basic Administration
-
auths
(1)
-
svcs
(1)
-
svcadm
(1M)
-
svccfg
(1M)
-
useradd
(1M)
-
usermod
(1M)
-
rbac
(5)
-
smf_security
(5)