(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

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

Inkling Research Inc.

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
Content-Type: text/plain; charset="us-ascii"


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
# apache2
# Chris Miles 20050624

. /lib/svc/share/smf_include.sh


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

        logger -p daemon.warning -t apache2 "$1"
        echo "$1" >&2

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

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

                /apps/apache7/prefork/bin/apachectl -k graceful

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

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


cat apache7.xml
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM
    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"/>
<dependency name="paths" grouping="require_all" restart_on="none"
<service_fmri value="file://localhost/apps/apache7/prefork/bin/apachectl"/>
<service_fmri value="file://localhost/apps/apache7/prefork/bin/httpd"/>
<dependency name="network" grouping="require_any" restart_on="none"
<service_fmri value="svc:/network/service"/>
<dependent name="apache2_multi-user" grouping="optional_all"
<service_fmri value="svc:/milestone/multi-user"/>

                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"/>
<loctext xml:lang="C">Apache 2 (httpd)</loctext>
<manpage title="httpd" section="8"/>
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