Merge "Clean up zuul-scheduler init script"
This commit is contained in:
commit
c2865118c9
|
@ -5,15 +5,15 @@
|
|||
# Required-Stop: $remote_fs $syslog
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Zuul Scheduler
|
||||
# Description: Trunk gating system launcher
|
||||
# Short-Description: Zuul scheduler
|
||||
# Description: Trunk gating system
|
||||
### END INIT INFO
|
||||
|
||||
# Do NOT "set -e"
|
||||
|
||||
# PATH should only include /usr/* if it runs after the mountnfs.sh script
|
||||
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
|
||||
DESC="Zuul Scheduler"
|
||||
PATH=/sbin:/usr/sbin:/bin:/usr/bin
|
||||
DESC="Zuul"
|
||||
NAME=zuul-scheduler
|
||||
DAEMON=/usr/local/bin/zuul-scheduler
|
||||
PIDFILE=/var/run/$NAME/$NAME.pid
|
||||
|
@ -42,7 +42,7 @@ do_start()
|
|||
# 0 if daemon has been started
|
||||
# 1 if daemon was already running
|
||||
# 2 if daemon could not be started
|
||||
# 3 if pid file already exist
|
||||
# 3 if pid file exits already
|
||||
|
||||
mkdir -p /var/run/$NAME
|
||||
chown $USER /var/run/$NAME
|
||||
|
@ -66,8 +66,41 @@ do_start()
|
|||
#
|
||||
do_stop()
|
||||
{
|
||||
$DAEMON stop
|
||||
return 0
|
||||
# Return
|
||||
# 0 if daemon has been stopped
|
||||
# 1 if daemon was already stopped
|
||||
# 2 if daemon could not be stopped
|
||||
# other if a failure occurred
|
||||
start-stop-daemon --stop --signal 9 --pidfile $PIDFILE
|
||||
RETVAL="$?"
|
||||
[ "$RETVAL" = 2 ] && return 2
|
||||
rm -f /var/run/$NAME/*
|
||||
return "$RETVAL"
|
||||
}
|
||||
|
||||
#
|
||||
# Function that stops the daemon/service
|
||||
#
|
||||
do_graceful_stop()
|
||||
{
|
||||
PID=`cat $PIDFILE`
|
||||
kill -USR1 $PID
|
||||
|
||||
# wait until really stopped
|
||||
if [ -n "${PID:-}" ]; then
|
||||
i=0
|
||||
while kill -0 "${PID:-}" 2> /dev/null; do
|
||||
if [ $i -eq '0' ]; then
|
||||
echo -n " ... waiting "
|
||||
else
|
||||
echo -n "."
|
||||
fi
|
||||
i=$(($i+1))
|
||||
sleep 1
|
||||
done
|
||||
fi
|
||||
|
||||
rm -f /var/run/$NAME/*
|
||||
}
|
||||
|
||||
#
|
||||
|
@ -91,7 +124,7 @@ case "$1" in
|
|||
case "$?" in
|
||||
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
||||
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
||||
3) echo "Pidfile at $PIDFILE already exists, run service zuul-launcher stop to clean up."
|
||||
3) echo "Pidfile at $PIDFILE already exists, run service zuul-scheduler stop to clean up." ;;
|
||||
esac
|
||||
;;
|
||||
stop)
|
||||
|
@ -103,8 +136,8 @@ case "$1" in
|
|||
esac
|
||||
;;
|
||||
status)
|
||||
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
|
||||
;;
|
||||
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
|
||||
;;
|
||||
reload|force-reload)
|
||||
#
|
||||
# If do_reload() is not implemented then leave this commented out
|
||||
|
@ -120,7 +153,7 @@ case "$1" in
|
|||
# 'force-reload' alias
|
||||
#
|
||||
log_daemon_msg "Restarting $DESC" "$NAME"
|
||||
do_stop
|
||||
do_graceful_stop
|
||||
do_start
|
||||
;;
|
||||
*)
|
||||
|
|
|
@ -31,6 +31,17 @@ class zuul::executor (
|
|||
],
|
||||
}
|
||||
|
||||
if ($::operatingsystem == 'Ubuntu') and ($::operatingsystemrelease >= '16.04') {
|
||||
# This is a hack to make sure that systemd is aware of the new service
|
||||
# before we attempt to start it.
|
||||
exec { 'zuul-executor-systemd-daemon-reload':
|
||||
command => '/bin/systemctl daemon-reload',
|
||||
before => Service['zuul-executor'],
|
||||
subscribe => File['/etc/init.d/zuul-executor'],
|
||||
refreshonly => true,
|
||||
}
|
||||
}
|
||||
|
||||
service { 'zuul-executor':
|
||||
ensure => $ensure,
|
||||
name => 'zuul-executor',
|
||||
|
|
|
@ -20,6 +20,16 @@ class zuul::scheduler (
|
|||
$layout_dir = '',
|
||||
$manage_log_conf = true,
|
||||
) {
|
||||
if ($::operatingsystem == 'Ubuntu') and ($::operatingsystemrelease >= '16.04') {
|
||||
# This is a hack to make sure that systemd is aware of the new service
|
||||
# before we attempt to start it.
|
||||
exec { 'zuul-scheduler-systemd-daemon-reload':
|
||||
command => '/bin/systemctl daemon-reload',
|
||||
before => Service['zuul-scheduler'],
|
||||
subscribe => File['/etc/init.d/zuul-scheduler'],
|
||||
refreshonly => true,
|
||||
}
|
||||
}
|
||||
service { 'zuul-scheduler':
|
||||
ensure => $ensure,
|
||||
enable => true,
|
||||
|
|
Loading…
Reference in New Issue