(no subject)

From: Tim Wort <tim_at_pobox.com>
Date: Wed Jul 17 2013 - 09:35:02 EDT
Your manifest will restart apache on a failure, the default for SMF, that
can be changed but probably not what you want.

You say users use sudo to stop and start apache.  How do they do that?
 What script?

Here are some possibilities.

They are using a script that is a legacy run control script, located in
/etc/init.d and linked to rc directories, if that script uses svcadm to
enable the service then it remains enabled.  The rc-scripts are not called
on shutdown like they were in the past.

Even if your users are doing svcadm disable <apache> the above rc script
will start it again.

If the rc-script I mention exists change it to run svcadm enable -t
<apache>, disable apache - svcadm disable <apache>.  A svcadm disable
updates the repository with the disable state. This is persistent, as is a
enable.  After starting the disabled service with the -t (temporary) option
the repository state remains unchanged.

Your users are not using svcadm enable/disable directly or you would not
have the issue unless some other start/stop method is being invoked.

If your users are using the method script directly... they should not.

If what you want is no restart on failure or a rude shutdown then you need
to change the mainvest to be transient but this would not be a good idea.

Your current manifest will use a contract, svc-started spawns the contract
on apaches behalf and each process inherits that contract and the contract
reports process failure to svc.startd which inturn restarts the process in
question.

To make the service transient so it is not restarted by svc.startd on
failure you need to add a startd property group with a value=transient
field.  But this is not a good idea for apache and will cause undesirable
behavior.

Inkling Research Inc.
Tim.Wort@InklingResearch.com
Tim@timwort.org

Date: Thu, 11 Jul 2013 11:12:56 -0500
From: Kartik Vashishta <kartik.unix@gmail.com>
Subject: Apache SMF restarts apache automatically
To: sunmanagers@sunmanagers.org
Message-ID:
        <CAJFC5W2iSLzETuwZqFKdOb1QJ3HfJa-M+4sym2sW3DLGknaskg@mail.gmail.com>
Content-Type: text/plain; charset="us-ascii"

Hi,

I do not want apache to be restarted, I have given user sudo access to
apachectl to stop and restart, however, when user stops it, it get's
restarted automatically. here are the files:

vi /usr/local/svc/method/apache7
"/usr/local/svc/method/apache7" 56 lines, 1209 characters
#!/sbin/sh
#
# apache2
#
# Chris Miles 20050624
#

. /lib/svc/share/smf_include.sh

PATH=${PATH}:/apps/apache7/prefork/bin
APACHECONF=/apps/apache7/prefork/conf/httpd.conf
PIDFILE=/apps/apache7/prefork/logs/httpd.pid

if [ -f $PIDFILE ] ; then
        pid=`cat $PIDFILE 2>/dev/null`
else
        pid=`pgrep httpd`
fi

logmsg()
{
        logger -p daemon.warning -t apache2 "$1"
        echo "$1" >&2
}

case "$1" in
        start)
                [ ! -f ${APACHECONF} ] && exit 0
                [ -n "$pid" ] && kill -TERM $pid 2>/dev/null
                /apps/apache7/prefork/bin/apachectl -k start
                if [ $? -ne 0 ]
                then
                        exit $SMF_EXIT_ERR_CONIG
                fi
                ;;

        stop)
                /apps/apache7/prefork/bin/apachectl -k stop
                ;;

        reload)
                /apps/apache7/prefork/bin/apachectl -k graceful
                ;;

        restart)
                /apps/apache7/prefork/bin/apachectl -k restart
                ;;

        *)
                echo "Usage: $0 \c" >&2
                echo "(start|stop|reload|restart)" >&2
                exit 1
                ;;

esac
exit $SMF_EXIT_OK


cat apache7.xml
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM
"/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<!--
    Apache2 SMF Manifest
    Chris Miles 20050624
 -->
<service_bundle type="manifest" name="site:apache7">
<service name="site/apache7" type="service" version="1">
<create_default_instance enabled="false"/>
<single_instance/>
<dependency name="paths" grouping="require_all" restart_on="none"
type="path">
<service_fmri value="file://localhost/apps/apache7/prefork/bin/apachectl"/>
<service_fmri value="file://localhost/apps/apache7/prefork/bin/httpd"/>
<service_fmri
value="file://localhost/apps/apache7/prefork/conf/httpd.conf"/>
</dependency>
<dependency name="network" grouping="require_any" restart_on="none"
type="service">
<service_fmri value="svc:/network/service"/>
</dependency>
<dependent name="apache2_multi-user" grouping="optional_all"
restart_on="none">
<service_fmri value="svc:/milestone/multi-user"/>
</dependent>
<!--

                The timeout needs to be large enough to wait for startup.

-->
<exec_method type="method" name="start" exec="/usr/local/svc/method/apache7
start" timeout_seconds="60"/>
<exec_method type="method" name="stop" exec="/usr/local/svc/method/apache7
stop" timeout_seconds="60"/>
<stability value="Unstable"/>
<template>
<common_name>
<loctext xml:lang="C">Apache 2 (httpd)</loctext>
</common_name>
<documentation>
<manpage title="httpd" section="8"/>
</documentation>
</template>
</service>
</service_bundle>
Received on Wed Jul 17 09:35:31 2013

This archive was generated by hypermail 2.1.8 : Wed Mar 23 2016 - 09:24:59 EDT