A través de la utilidad administrativa de Glassfish asadmin
, es posible configurar el arranque automático tanto del dominio como de las diferentes instancias que maneja. El resultado final es la integración total de Glassfish en Solaris Service Management Facility (SMF).
El comando de asadmin que utilizaremos es create-service
, tanto para el dominio con las instancias (con diferentes parámetros). Hay que tener en cuenta que si Glassfish se ejecuta usando un usuario sin privilegios (lo habitual), no tendrá permisos para crear o modificar servicios de SMF. Os explicaré como hacerlo como root y después dar el cambiazo.
Arranque automático de dominio
Como root, ejecutaremos la utilidad asadmin, disponible en el directorio bin/ de nuestra instalación de Glassfish con el subcomando create-service:
root@localhost:/opt/oracle/glassfish3/bin# ./asadmin Use "exit" to exit and "help" for online help. asadmin> asadmin> 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:/opt/oracle/glassfish3/glassfish/domains Manifest file location on the system:/var/svc/manifest/application/GlassFish/domain1_opt_oracle_glassfish3_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 For your convenience this message has also been saved to this file: /opt/oracle/glassfish3/glassfish/domains/domain1/PlatformServices.log Command create-service executed successfully.
Con esto ya tenemos el servicio creado, pero se ejecuta como root. El siguiente comando modifica el servicio para que corra con nuestro usuario dedicado «foo»:
root@localhost:/opt/oracle/glassfish3/bin# svccfg -s svc:/application/GlassFish/domain1:default setprop start/user = astring: foo root@localhost:/opt/oracle/glassfish3/bin# svcadm refresh svc:/application/GlassFish/domain1:default
Una vez realizado el cambio, ya se puede arrancar el servicio:
root@localhost:/opt/oracle/glassfish3/bin# svcadm disable svc:/application/GlassFish/domain1:default root@localhost:/opt/oracle/glassfish3/bin# svcadm enable svc:/application/GlassFish/domain1:default
Arranque automático de instancias
El proceso es el mismo que para el dominio, pero en este caso pasando a create-service el nombre de la instancia. Ejemplo para la instancia glassfish01:
asadmin> create-service glassfish01 The Service was created successfully. Here are the details: Name of the service:application/GlassFish/glassfish01 Type of the service:Instance Configuration location of the service:/opt/oracle/glassfish3/glassfish/nodes/localhost-domain1 Manifest file location on the system:/var/svc/manifest/application/GlassFish/glassfish01_opt_oracle_glassfish3_glassfish_nodes_localhost-domain1/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 glassfish01 // status * /usr/sbin/svcadm enable glassfish01 // start * /usr/sbin/svcadm disable glassfish01 // stop * /usr/sbin/svccfg delete glassfish01 // uninstall For your convenience this message has also been saved to this file: /opt/oracle/glassfish3/glassfish/nodes/localhost-domain1/glassfish01/PlatformServices.log Command create-service executed successfully.
Y lo mismo, modificamos el usuario de ejecución para que no sea root:
svccfg -s svc:/application/GlassFish/glassfish01:default setprop start/user = astring: foo svcadm refresh svc:/application/GlassFish/glassfish01 svcadm disable svc:/application/GlassFish/glassfish01 svcadm enable svc:/application/GlassFish/glassfish01