This article describes how you can create a Service Manager Facility (SMF) for JBoss AS on Solaris/OpenSolaris. What is an SMF service at first ? if you are new to Solaris administration we will give here a short description about it.
SMF is a new feature of the Solaris Operating System that creates a supported, unified model for services and service management on each Solaris system. It is a core part of the Predictive Self-Healing technology available in Solaris 10.
The Service Management Facility contains several improvements compared to the standard service administration model. For example:
-
Services can be easily queried using the new svcs command and managed through the svcadm and svccfg command.
-
SMF failed services are automatically restarted in dependency order, whether they failed as the result of administrator error, software bug, or were affected by an uncorrectable hardware error.
- If you experience problems in the boot process then you can easily debug the source of the problem because startup messages are logged and verbosity can be configured.
For a detailed list of SMF features you can visit the following link:
That being said, let’s see how this can be combined with JBoss startup/shutdown service. Historically, all releases of JBoss include a startup/shutdown script for both Windows and Unix environment (You can read more about this at this link ). However what these scripts do is controlling starting/stopping of the application server when the host is booted or shut down, or on demand.
In order to produce an SMF service for JBoss as we need two files:
-
The XML service descriptor
-
A shell script which ultimately handles starting and stopping the application server
Let’s see at first the XML descriptor, which will be named jboss.xml
<?xml version="1.0"?> <!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1"> <service_bundle type='manifest' name='jboss'> <service name='application/jboss' type='service' version='1'> <!-- Wait for network interfaces to be initialized. --> <dependency name='network' grouping='require_all' restart_on='none' type='service'> <service_fmri value='svc:/milestone/network:default' /> </dependency> <!-- Wait for all local filesystems to be mounted. --> <dependency name='filesystem-local' grouping='require_all' restart_on='none' type='service'> <service_fmri value='svc:/system/filesystem/local:default' /> </dependency> <!-- Wait for the production database to be online <dependency name='database' grouping='require_all' restart_on='restart' type='service'> <service_fmri value='svc:/application/database/mysql:version_51' /> </dependency> --> <exec_method type='method' name='start' exec='/lib/svc/method/jboss %m %i' timeout_seconds='60' /> <exec_method type='method' name='stop' exec='/lib/svc/method/jboss %m %i' timeout_seconds='60' /> <!-- rememer to set home dir of jboss user (usermod -d /opt/jboss5/ jboss) --> <property_group name="jboss" type="application"> <propval name="home" type="astring" value="/opt/jboss5" override="true"/> <propval name="user" type="astring" value="jboss" override="true"/> </property_group> <!-- set this to productions values: # svccfg -s svc:/application/jboss:default setprop instance/host=0.0.0.0 # svcadm refresh jboss:default --> <instance name='default' enabled='false'> <property_group name='instance' type='application'> <propval name='host' type='astring' value='127.0.0.1' /> <propval name="partition" type="astring" value="" override="true"/> <propval name="udp_address" type="astring" value="" override="true"/> <propval name="udp_port" type="astring" value="" override="true"/> <propval name="properties" type="astring" value="" override="true"/> </property_group> </instance> <instance name='all' enabled='false'> <property_group name='instance' type='application'> <propval name='host' type='astring' value='127.0.0.1' /> <propval name="partition" type="astring" value="" override="true"/> <propval name="udp_address" type="astring" value="" override="true"/> <propval name="udp_port" type="astring" value="" override="true"/> <propval name="properties" type="astring" value="" override="true"/> </property_group> </instance> <instance name='minimal' enabled='false'> <property_group name='instance' type='application'> <propval name='host' type='astring' value='127.0.0.1' /> <propval name="partition" type="astring" value="" override="true"/> <propval name="udp_address" type="astring" value="" override="true"/> <propval name="udp_port" type="astring" value="" override="true"/> <propval name="properties" type="astring" value="" override="true"/> </property_group> </instance> <instance name='standard' enabled='false'> <property_group name='instance' type='application'> <propval name='host' type='astring' value='127.0.0.1' /> <propval name="partition" type="astring" value="" override="true"/> <propval name="udp_address" type="astring" value="" override="true"/> <propval name="udp_port" type="astring" value="" override="true"/> <propval name="properties" type="astring" value="" override="true"/> </property_group> </instance> <instance name='web' enabled='false'> <property_group name='instance' type='application'> <propval name='host' type='astring' value='127.0.0.1' /> <propval name="partition" type="astring" value="" override="true"/> <propval name="udp_address" type="astring" value="" override="true"/> <propval name="udp_port" type="astring" value="" override="true"/> <propval name="properties" type="astring" value="" override="true"/> </property_group> </instance> <stability value='Stable' /> <template> <common_name> <loctext xml:lang='C'>JBoss AS</loctext> </common_name> <documentation> <doc_link name='jboss.org' uri='http://www.jboss.org/jbossas/docs.html' /> </documentation> </template> </service> </service_bundle>