3 # A single executable which starts necessary glance server components
5 # Create a workspace-specific glance config directory and
6 # wrap the glance-api and glance-registry procs.
9 # USAGE: ./glance_start_wrapper <glance_conf_dir>
14 echo "error: specifiy the glance conf dir"
19 if [ ! -d "${src_conf_dir}" ]; then
20 echo "error: glance conf dir does not exist"
24 if [ -z ${RIFT_INSTALL+x} ]; then
25 echo "error: RIFT_INSTALL is not set"
29 if [ -z "${RIFT_VAR_ROOT}" ]; then
30 if [ -n "${RIFT_INSTALL}" ]; then
31 RIFT_VAR_ROOT="${RIFT_INSTALL}/var"
33 RIFT_VAR_ROOT="$(mktemp -d)"
34 echo "warning: RIFT_VAR_ROOT or RIFT_INSTALL not provided, using temporary directory"
38 dest_conf_dir="${RIFT_VAR_ROOT}/glance/conf"
39 echo "destination glance conf directory: ${dest_conf_dir}"
41 if [ -e "${dest_conf_dir}" ]; then
42 echo "removing ${dest_conf_dir}"
43 #rm -rf "${dest_conf_dir}"
46 mkdir -p "${dest_conf_dir}"
48 for conf_file in ${src_conf_dir}/*; do
49 cp "${conf_file}" ${dest_conf_dir}/
50 dest_file="${dest_conf_dir}/$(basename ${conf_file})"
51 sed -i "s|{RIFT_VAR_ROOT}|${RIFT_VAR_ROOT}|g" "${dest_file}"
52 sed -i "s|{RIFT_INSTALL}|${RIFT_INSTALL}|g" "${dest_file}"
55 mkdir -p ${RIFT_VAR_ROOT}/log/glance
61 function kill_children(){
67 if [ ${registry_pid} -ne 0 ]; then
68 kill ${registry_pid} 2>/dev/null
71 if [ ${api_pid} -ne 0 ]; then
72 kill ${api_pid} 2>/dev/null
77 if [ ${registry_pid} -ne 0 ]; then
78 echo "KILL registry pid: ${registry_pid}"
79 kill -9 ${registry_pid} 2>/dev/null
82 if [ ${api_pid} -ne 0 ]; then
83 echo "KILL api pid: ${api_pid}"
84 kill -9 ${api_pid} 2>/dev/null
91 function kill_group(){
92 # Kill any remaining children
99 trap "kill_children" SIGHUP SIGINT SIGTERM SIGTRAP EXIT
100 trap "kill_group" SIGCHLD
102 glance-registry --config-dir ${dest_conf_dir} --config-file ${dest_conf_dir}/glance-registry.conf >/dev/null 2>&1&
104 if [ $? -ne 0 ]; then
105 echo "ERROR: Glance registry startup failed!" >&2
109 glance-api --config-dir ${dest_conf_dir} --config-file ${dest_conf_dir}/glance-api.conf >/dev/null 2>&1&
111 if [ $? -ne 0 ]; then
112 echo "ERROR: Glance registry startup failed!" >&2
119 if [ -e "${dest_conf_dir}/glance-manage.conf" ]; then
120 manage_cfg="--config-file ${dest_conf_dir}/glance-manage.conf"
123 glance-manage --config-dir ${dest_conf_dir} ${manage_cfg} db_sync >/dev/null 2>&1&
124 if [ $? -ne 0 ]; then
125 echo "ERROR: glance-manage db_sync failed" >&2