2016-02-02 00:12:58 +05:30
|
|
|
# start / stop / status functions for supervise-daemon
|
|
|
|
|
|
|
|
# Copyright (c) 2016 The OpenRC Authors.
|
|
|
|
# See the Authors file at the top-level directory of this distribution and
|
|
|
|
# https://github.com/OpenRC/openrc/blob/master/AUTHORS
|
|
|
|
#
|
|
|
|
# This file is part of OpenRC. It is subject to the license terms in
|
|
|
|
# the LICENSE file found in the top-level directory of this
|
|
|
|
# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
|
|
|
|
# This file may not be copied, modified, propagated, or distributed
|
|
|
|
# except according to the terms contained in the LICENSE file.
|
|
|
|
|
|
|
|
supervise_start()
|
|
|
|
{
|
|
|
|
if [ -z "$command" ]; then
|
|
|
|
ewarn "The command variable is undefined."
|
|
|
|
ewarn "There is nothing for ${name:-$RC_SVCNAME} to start."
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
ebegin "Starting ${name:-$RC_SVCNAME}"
|
|
|
|
eval supervise-daemon --start \
|
2016-05-20 04:29:40 +05:30
|
|
|
${chroot:+--chroot} $chroot \
|
2016-02-02 00:12:58 +05:30
|
|
|
${pidfile:+--pidfile} $pidfile \
|
|
|
|
${command_user+--user} $command_user \
|
|
|
|
$supervise_daemon_args \
|
|
|
|
$command \
|
|
|
|
-- $command_args $command_args_foreground
|
|
|
|
rc=$?
|
2016-05-20 04:29:40 +05:30
|
|
|
if [ $rc = 0 ]; then
|
|
|
|
[ -n "${chroot}" ] && service_set_value "chroot" "${chroot}"
|
|
|
|
[ -n "${pidfile}" ] && service_set_value "pidfile" "${pidfile}"
|
|
|
|
fi
|
2016-09-13 22:57:08 +05:30
|
|
|
eend $rc "failed to start ${name:-$RC_SVCNAME}"
|
2016-02-02 00:12:58 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
supervise_stop()
|
|
|
|
{
|
2016-05-20 04:29:40 +05:30
|
|
|
local startchroot="$(service_get_value "chroot")"
|
2016-02-02 00:12:58 +05:30
|
|
|
local startpidfile="$(service_get_value "pidfile")"
|
2016-05-20 04:29:40 +05:30
|
|
|
chroot="${startchroot:-$chroot}"
|
2016-02-02 00:12:58 +05:30
|
|
|
pidfile="${startpidfile:-$pidfile}"
|
|
|
|
[ -n "$pidfile" ] || return 0
|
|
|
|
ebegin "Stopping ${name:-$RC_SVCNAME}"
|
|
|
|
supervise-daemon --stop \
|
2016-05-20 04:29:40 +05:30
|
|
|
${pidfile:+--pidfile} $chroot$pidfile \
|
2016-02-02 00:12:58 +05:30
|
|
|
${stopsig:+--signal} $stopsig
|
|
|
|
|
2016-09-13 22:57:08 +05:30
|
|
|
eend $? "Failed to stop ${name:-$RC_SVCNAME}"
|
2016-02-02 00:12:58 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
supervise_status()
|
|
|
|
{
|
|
|
|
_status
|
|
|
|
}
|