create-service

create-service

Configures the starting of a DAS or a Eclipse GlassFish instance on an unattended boot

Synopsis

asadmin [asadmin-options] create-service [--help]
[--name service-name]
[--serviceproperties service-properties]
[--dry-run={false|true}] [--force={false|true}]
[--serviceuser service-user]
[--domaindir domain-dir]
[--nodedir node-dir] [--node node]
[domain-or-instance-name]

Description

The create-service subcommand configures the starting of a domain administration server (DAS) or a Eclipse GlassFish instance on an unattended boot on Windows and Linux systems.

If no operand is specified and the domains directory contains only one domain, the subcommand configures the starting of the DAS for the default domain. If no operand is specified and the domains directory contains multiple domains, an error occurs.

If the operand specifies an instance, the create-service subcommand does not contact the domain administration server (DAS) to determine the node on which the instance resides. To determine the node on which the instance resides, the subcommand searches the directory that contains the node directories. If multiple node directories exist, the node must be specified as an option of the subcommand.

The subcommand contains internal logic to determine whether the supplied operand is a DAS or an instance.

This subcommand is supported in local mode only.

Behavior of create-service on Windows Systems

On Windows systems, the create-service subcommand creates a Windows service to represent the DAS or instance. The service is created in the automatic 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.

On Windows systems, this subcommand must be run as the OS-level administrator user.

The subcommand creates the following Windows Services Wrapper files for the service in the domain-dir\bin directory or the instance-dir\bin directory:

  • Configuration file: service-nameService.xml

  • Executable file: service-nameService.exe

On Windows systems, this subcommand requires the Microsoft .NET Framework 4.6.1 or later (https://dotnet.microsoft.com/). Otherwise, the subcommand fails.

Behavior of create-service on Linux Systems

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 the `/etc/rc?.d directories. After this subcommand creates the script, you must use this script to start, stop, or restart the domain or instance.

On Linux systems, this subcommand must be run as the OS-level root user.

Options

asadmin-options

Options for the asadmin utility. For information about these options, see the asadmin(1M) help page.

--help
-?

Displays the help text for the subcommand.

--name

(Windows systems only) The name of the service that you will use when administering the service through the service management features of the Windows operating system. The default is the name of the domain or instance that is specified as the operand of this subcommand.

--serviceproperties

Specifies a colon(:)-separated list of various properties that are specific to the service.
To customize the display name of the service in the Windows Service list, set the DISPLAY_NAME property to the required name.

--dry-run
-n

Previews your attempt to create a service. Indicates issues and the outcome that will occur if you run the command without using the --dry-run option. Nothing is actually configured. Default is false.

--force

Specifies whether the service is created even if validation of the service fails.
Possible values are as follows:

true

The service is created even if validation of the service fails.

false

The service is not created (default).

--serviceuser

(Linux systems only) The user that is to run the Eclipse GlassFish software when the service is started. The default is the user that is running the subcommand. Specify this option if the Eclipse GlassFish software is to be run by a user other than the root user.

--domaindir

The absolute path of the directory on the disk that contains the configuration of the domain. If this option is specified, the operand must specify a domain.

--nodedir

Specifies the directory that contains the instance’s node directory. The instance’s files are stored in the instance’s node directory. The default is as-install/nodes. If this option is specified, the operand must specify an instance.

--node

Specifies the node on which the instance resides. This option may be omitted only if the directory that the --nodedir option specifies contains only one node directory. Otherwise, this option is required. If this option is specified, the operand must specify an instance.

Operands

domain-or-instance-name

The name of the domain or instance to configure. If no operand is specified, the default domain is used.

Examples

Example 1   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
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 Eclipse GlassFish
Server Directory: C:\glassfish7\glassfish\domains\domain1
Configuration file for Windows Services Wrapper: C:\glassfish7\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:\glassfish7\glassfish\domains\domain1\bin\domain1Service.exe  start
Stop Command:   C:\glassfish7\glassfish\domains\domain1\bin\domain1Service.exe  stop
Restart Command:  C:\glassfish7\glassfish\domains\domain1\bin\domain1Service.exe
restart
Uninstall Command:  C:\glassfish7\glassfish\domains\domain1\bin\domain1Service.exe
uninstall
Install Command:  C:\glassfish7\glassfish\domains\domain1\bin\domain1Service.exe
install
Status Command: C:\glassfish7\glassfish\domains\domain1\bin\domain1Service.exe status
You can also verify that the service is installed (or not) with sc query state= all
windows.services.uninstall.good=Found the Windows Service and successfully uninstall
it.
For your convenience this message has also been saved to this file:
C:\glassfish7\glassfish\domains\domain1\PlatformServices.log
Command create-service executed successfully.

Example 2   Creating a Service on a Linux System

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/glassfish7/glassfish/domains/domain1/PlatformServices.log
Command create-service executed successfully.

Exit Status

0

subcommand executed successfully

1

error in executing the subcommand

See Also

Microsoft .NET Framework (https://dotnet.microsoft.com/)