Project

General

Profile

LighttpdOnSolaris » History » Revision 2

Revision 1 (Anonymous, 2005-09-25 12:25) → Revision 2/16 (Anonymous, 2005-09-25 14:18)

= Running lighttpd on Solaris Service Management Facility (SMF) = 

 If you want to use native Solaris management facility (SMF), you have to create two files describing lighttpd service: 

  * Manifest file: /var/svc/manifest/network/lighttpd.xml 

 {{{ 
 <?xml version="1.0"?> 
 <!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1"> 
 <!-- 
     Copyright 2005 Sergiusz Pawlowicz.    All rights reserved. 
     http://pawlowicz.name/ 
     Use is subject to license terms. 

     ident         "0.1" 
 --> 

 <service_bundle type='manifest' name='lighttpd'> 

 <service 
         name='network/lighttpd' 
         type='service' 
         version='1'> 

         <!-- 
           Because we may have multiple instances of network/http 
           provided by different implementations, we keep dependencies 
           and methods within the instance. 
         --> 

         <instance name='lighttpd' enabled='false'> 
                 <dependency name='loopback' 
                     grouping='require_all' 
                     restart_on='error' 
                     type='service'> 
                         <service_fmri value='svc:/network/loopback:default'/> 
                 </dependency> 

                 <dependency name='physical' 
                     grouping='optional_all' 
                     restart_on='error' 
                     type='service'> 
                         <service_fmri value='svc:/network/physical:default'/> 
                 </dependency> 

                 <exec_method 
                         type='method' 
                         name='start' 
                         exec='/lib/svc/method/http-lighttpd start' 
                         timeout_seconds='60' /> 

                 <exec_method 
                         type='method' 
                         name='stop' 
                         exec='/lib/svc/method/http-lighttpd stop' 
                         timeout_seconds='60' /> 

                 <exec_method 
                         type='method' 
                         name='refresh' 
                         exec='/lib/svc/method/http-lighttpd refresh' 
                         timeout_seconds='60' /> 

                 <property_group name='startd' type='framework'> 
                         <!-- sub-process core dumps shouldn't restart 
                                 session --> 
                         <propval name='ignore_error' type='astring' 
                                 value='core,signal' /> 
                 </property_group> 

         </instance> 

         <template> 
                 <common_name> 
                         <loctext xml:lang='C'> 
                                 Lighttpd HTTP server 
                         </loctext> 
                 </common_name> 
                 <documentation> 
                         <manpage title='lighttpd' section='1M' /> 
                         <doc_link name='lighttpd.net' 
                                 uri='http://www.lighttpd.net/' /> 
                 </documentation> 
         </template> 
 </service> 

 </service_bundle> 
 }}} 

  * init file: /lib/svc/method/http-lighttpd 

 {{{ 
 #!/sbin/sh 
 # 
 # Copyright 2005 Sergiusz Pawlowicz    All rights reserved. 
 # Use is subject to license terms. 
 # 
 # ident "0.1" 
 # 


 LIGHTTPD_HOME=/global/lighttpd 
 CONF_FILE=/etc/lighttpd/lighttpd.conf 
 PIDFILE=/var/run/lighttpd.pid 

 [ ! -f ${CONF_FILE} ] &&    exit $CONF_FILE 

 case "$1" in 
 start) 
         /bin/rm -f ${PIDFILE} 
         exec ${LIGHTTPD_HOME}/sbin/lighttpd -f ${CONF_FILE} 2>&1 
         ;; 
 refresh) 
         if [ -f "$PIDFILE" ]; then 
                 /usr/bin/kill -HUP `/usr/bin/cat $PIDFILE` 
         fi 
         ;; 
 stop) 
         if [ -f "$PIDFILE" ]; then 
                 /usr/bin/kill -QUIT `/usr/bin/cat $PIDFILE` 
         fi 
         ;; 
 *) 
         echo "Usage: $0 {start|stop|refresh}" 
         exit 1 
         ;; 
 esac 
 }}} 

 Now import the file into SMF database: 

 {{{ 
 bash-3.00# svccfg import /var/svc/manifest/network/lighttpd.conf 
 }}} 

 and enable this service: 

 {{{ 
 bash-3.00# svcadm enable network/lighttpd 
 }}} 

 Lastly, you can check verbose information about this service: 

 {{{ 
 bash-3.00# svcs -l network/lighttpd 
 fmri           svc:/network/lighttpd:lighttpd 
 name           Lighttpd HTTP server 
 enabled        true 
 state          online 
 next_state     none 
 state_time     Sun Sep 25 14:21:49 2005 
 logfile        /var/svc/log/network-lighttpd:lighttpd.log 
 restarter      svc:/system/svc/restarter:default 
 contract_id    143 
 dependency     require_all/error svc:/network/loopback:default (online) 
 dependency     optional_all/error svc:/network/physical:default (online) 
 }}} 

 Of course it is simple example of such a service, if you have better one, please cut and paste it here.