Skip to content

Commit

Permalink
Solaris: sync SMF method script and XML description with PE
Browse files Browse the repository at this point in the history
This adds contract handling and avoids going into maintenance state when
there's a stale PID file at startup.
  • Loading branch information
bazsi committed Jan 9, 2011
1 parent 0229da0 commit 9b4390a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions contrib/solaris-packaging/syslog-ng.example.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<exec_method
type='method'
name='restart'
exec='/lib/svc/method/syslog-ng %m'
exec='/lib/svc/method/syslog-ng %m %{restarter/contract}'
timeout_seconds='60'>
<method_context>
<method_credential user='root' />
Expand All @@ -74,7 +74,7 @@
<exec_method
type='method'
name='stop'
exec='/lib/svc/method/syslog-ng %m'
exec='/lib/svc/method/syslog-ng %m %{restarter/contract}'
timeout_seconds='60' >
<method_context>
<method_credential user='root' />
Expand Down
17 changes: 10 additions & 7 deletions contrib/solaris-packaging/syslog-ng.method
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,16 @@ slng_waitforpid() {
}

slng_stop() {
[ -f $PIDFILE ] || return $SMF_EXIT_OK
syspid=`head -1 $PIDFILE`
# if we have a contract, we should simply use smf_kill_contract to terminate the process
if [ -n "$2" ]; then
smf_kill_contract $2 TERM 1 $MAXWAIT
[ $? -ne 0 ] && exit $SMF_EXIT_ERR_FATAL
return $SMF_EXIT_OK
fi

[ -f $PIDFILE ] || return $SMF_EXIT_ERR_FATAL

syspid=`head -1 $PIDFILE`

[ -z "$syspid" ] && return $SMF_EXIT_OK
kill -0 $syspid >/dev/null 2>&1
Expand All @@ -63,11 +70,7 @@ slng_stop() {
$_ret=$?
fi

if [ $_ret -ne 0 ] ;then
if [ -n "$2" ];then
smf_kill_contract "$2" TERM 10
[ $? -ne 0 ] && exit $SMF_EXIT_ERR_FATAL
fi
if [ $_ret -eq 0 ] ;then
rm -f $PIDFILE
if [ -h $SYSLOGPIDFILE ];then
rm -f $SYSLOGPIDFILE
Expand Down

0 comments on commit 9b4390a

Please sign in to comment.