Enable services with os-svc-enable
Split out the code which enables services to start on boot into a new os-svc-enable script. This script is currently called by os-svc-deamon so that services automatically start on first boot (as is the case with os-svc-install) The motivation here is to decouple service installation and enabling so that we can eventually avoid starting services on first boot until after they are configured. Auto starting services on boot like we currently do is causing lots of log ERROR messages, etc. Change-Id: I66d4660c169f5918e924eab1876134891c3a24a1
This commit is contained in:
parent
d359aed182
commit
4e482c192a
|
@ -1,4 +1,4 @@
|
|||
Command line utilities to simplify instalation of OpenStack services.
|
||||
Command line utilities to simplify installation of OpenStack services.
|
||||
|
||||
## os-svc-install
|
||||
Given a git repo url, pip-install the repo and all of its python dependencies into a virtualenv under /opt/stack/venvs.
|
||||
|
@ -6,7 +6,10 @@ Given a git repo url, pip-install the repo and all of its python dependencies in
|
|||
## os-svc-daemon
|
||||
Given a system service command line and run-as user, generate and install system service start script. See output of `os-svc-daemon -h` for online help.
|
||||
|
||||
## os-svc-enable-upstart
|
||||
## os-svc-enable
|
||||
Enable the given service name so it starts on boot.
|
||||
|
||||
## os-svc-enable-upstart (upstart distros only)
|
||||
Given an upstart job and an action, acts on the enabled or disabled state
|
||||
of jobs produced by os-svc-daemon. This requires the os-svc-enable upstart
|
||||
job which is installed by this element as well. There is also an action,
|
||||
|
@ -21,5 +24,8 @@ os-svc-install -u nova -n nova-all -c 'nova-all --someoption' -r https://github.
|
|||
|
||||
# install a system-start script for nova-api
|
||||
os-svc-daemon -e 'foo=bar bar=baz' -n nova-api -u nova -c /opt/stack/venvs/nova/bin/nova-api -- --config-dir /etc/nova
|
||||
```
|
||||
|
||||
# enable nova-api so that it starts on boot
|
||||
# NOTE: for now this is called in os-svc-daemon for legacy element support
|
||||
os-svc-enable -n nova-api
|
||||
```
|
||||
|
|
|
@ -88,6 +88,8 @@ start on runlevel [2345]
|
|||
stop on runlevel [016]
|
||||
$env_entries
|
||||
|
||||
OS_SVC_ENABLE_CONTROL=1
|
||||
|
||||
pre-start script
|
||||
mkdir -p /var/run/$user
|
||||
chown -R $user:$user /var/run/$user
|
||||
|
@ -143,8 +145,6 @@ ExecStartPre=/bin/mkdir -p /var/run/$user
|
|||
ExecStart=/bin/chown -R $user:$user /var/run/$user
|
||||
EOF
|
||||
|
||||
# Enable the service
|
||||
systemctl enable $name.service
|
||||
}
|
||||
|
||||
# TODO: SysV init fallback support
|
||||
|
@ -157,3 +157,9 @@ elif [ "$DIB_INIT_SYSTEM" == "systemd" ]; then
|
|||
fi
|
||||
install_systemd $SERVICENAME $RUNAS $RUNCMD $*
|
||||
fi
|
||||
|
||||
# Ideally we wouldn't enable services until *after* the first
|
||||
# time it gets configured. Until we update elements to support
|
||||
# this new logic we call os-svc-enable manually here for backwards
|
||||
# compatability.
|
||||
os-svc-enable -n $SERVICENAME
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2013 Red Hat, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
set -eu
|
||||
|
||||
usage() {
|
||||
echo "Usage: os-svc-enable -n SERVICENAME"
|
||||
echo ""
|
||||
echo " -h Show help and exit"
|
||||
echo " -n SERVICENAME Name of job/service file."
|
||||
echo ""
|
||||
}
|
||||
|
||||
SERVICENAME=${SERVICENAME:-""}
|
||||
|
||||
nshift=0
|
||||
while getopts "hn:" opt; do
|
||||
case "$opt" in
|
||||
n) SERVICENAME=$OPTARG;;
|
||||
h) usage; exit 0;;
|
||||
\?) usage; exit 1;;
|
||||
:) usage; exit 1;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $(($OPTIND-1))
|
||||
if [ -z "$SERVICENAME" ] ; then
|
||||
usage
|
||||
fi
|
||||
|
||||
function enable_upstart_service {
|
||||
local name=$1
|
||||
os-svc-enable-upstart $name enable
|
||||
}
|
||||
|
||||
function enable_systemd_service {
|
||||
local name=$1
|
||||
systemctl enable $name.service
|
||||
}
|
||||
|
||||
# TODO: SysV init fallback support
|
||||
DIB_INIT_SYSTEM=$(dib-init-system)
|
||||
if [ "$DIB_INIT_SYSTEM" == "upstart" ]; then
|
||||
enable_upstart_service $SERVICENAME
|
||||
elif [ "$DIB_INIT_SYSTEM" == "systemd" ]; then
|
||||
enable_systemd_service $SERVICENAME
|
||||
fi
|
|
@ -12,6 +12,7 @@ pip install -U virtualenv
|
|||
install -m 0755 -o root -g root $(dirname $0)/../bin/os-svc-install /usr/local/bin/os-svc-install
|
||||
install -m 0755 -o root -g root $(dirname $0)/../bin/os-svc-daemon /usr/local/bin/os-svc-daemon
|
||||
install -m 0755 -o root -g root $(dirname $0)/../bin/os-db-create /usr/local/bin/os-db-create
|
||||
install -m 0755 -o root -g root $(dirname $0)/../bin/os-svc-enable /usr/local/bin/os-svc-enable
|
||||
if [ "$(dib-init-system)" = "upstart" ] ; then
|
||||
install -m 0755 -o root -g root $(dirname $0)/../bin/os-svc-enable-upstart /usr/local/bin/os-svc-enable-upstart
|
||||
install -m 0644 -o root -g root $(dirname $0)/../upstart/os-svc-enable.conf /etc/init/os-svc-enable.conf
|
||||
|
|
Loading…
Reference in New Issue