Better handling of storm processes
Use devstack utilities to launch storm processes and be able to see their logs. Change-Id: Iccc30d411a49b9e47d6625909427f071397aedfd
This commit is contained in:
parent
d38b1de1d7
commit
58d927d083
|
@ -1,29 +0,0 @@
|
|||
# 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.
|
||||
#
|
||||
# Startup script for Storm Nimbus
|
||||
|
||||
[Unit]
|
||||
Description=Storm Nimbus daemon
|
||||
After=zookeeper.service kafka.service
|
||||
|
||||
[Service]
|
||||
User=storm
|
||||
Group=storm
|
||||
TimeoutStopSec=240
|
||||
WorkingDirectory=/opt/storm/current
|
||||
ExecStart=/opt/storm/current/bin/storm nimbus
|
||||
Restart=on-failure
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -1,29 +0,0 @@
|
|||
# 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.
|
||||
#
|
||||
# Startup script for Storm Supervisor
|
||||
|
||||
[Unit]
|
||||
Description=Storm Supervisor daemon
|
||||
After=storm-nimbus.service zookeeper.service kafka.service
|
||||
|
||||
[Service]
|
||||
User=storm
|
||||
Group=storm
|
||||
TimeoutStopSec=240
|
||||
WorkingDirectory=/opt/storm/current
|
||||
ExecStart=/opt/storm/current/bin/storm supervisor
|
||||
Restart=on-failure
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -0,0 +1,151 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright 2017 FUJITSU LIMITED
|
||||
#
|
||||
# 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.
|
||||
|
||||
# call_order:
|
||||
# - is_storm_enabled
|
||||
# - install_storm
|
||||
# - configure_storm
|
||||
# - clean_storm
|
||||
|
||||
_XTRACE_STORM=$(set +o | grep xtrace)
|
||||
set +o xtrace
|
||||
|
||||
STORM_USER="storm"
|
||||
STORM_GROUP="storm"
|
||||
|
||||
STORM_DIR="/opt/storm"
|
||||
STORM_CURRENT_DIR="${STORM_DIR}/current"
|
||||
STORM_BIN="${STORM_CURRENT_DIR}/bin/storm"
|
||||
STORM_WORK_DIR="/var/storm"
|
||||
STORM_LOG_DIR="/var/log/storm"
|
||||
|
||||
STORM_TARBALL="apache-storm-${STORM_VERSION}.tar.gz"
|
||||
STORM_TARBALL_DEST="${FILES}/${STORM_TARBALL}"
|
||||
|
||||
STORM_NIMBUS_CMD="${STORM_BIN} nimbus"
|
||||
STORM_SUPERVISOR_CMD="${STORM_BIN} supervisor"
|
||||
|
||||
function is_storm_enabled {
|
||||
[[ ,${ENABLED_SERVICES} =~ ,"monasca-storm" ]] && return 0
|
||||
return 1
|
||||
}
|
||||
|
||||
function start_storm {
|
||||
if is_storm_enabled; then
|
||||
echo_summary "Starting storm-{nimbus,supervisor}"
|
||||
run_process "monasca-storm-nimbus" "${STORM_NIMBUS_CMD}" "${STORM_GROUP}" "${STORM_USER}"
|
||||
run_process "monasca-storm-supervisor" "${STORM_SUPERVISOR_CMD}" "${STORM_GROUP}" "${STORM_USER}"
|
||||
fi
|
||||
}
|
||||
|
||||
function stop_storm {
|
||||
if is_storm_enabled; then
|
||||
echo_summary "Stopping storm-{nimbus,supervisor}"
|
||||
stop_process "monasca-storm-nimbus"
|
||||
stop_process "monasca-storm-supervisor"
|
||||
fi
|
||||
}
|
||||
|
||||
function clean_storm {
|
||||
if is_storm_enabled; then
|
||||
echo_summary "Cleaning storm"
|
||||
|
||||
sudo unlink "${DEST}/logs/storm-workers" || true
|
||||
sudo unlink "${STORM_CURRENT_DIR}/logs"|| true
|
||||
sudo unlink "${STORM_CURRENT_DIR}"|| true
|
||||
|
||||
sudo rm -rf "${DEST}/logs/storm-workers" || true
|
||||
sudo rm -rf "${STORM_CURRENT_DIR}"|| true
|
||||
sudo rm -rf "${STORM_DIR}" || true
|
||||
sudo rm -rf "${STORM_WORK_DIR}" || true
|
||||
sudo rm -rf "${STORM_LOG_DIR}" || true
|
||||
|
||||
sudo userdel "${STORM_USER}" || true
|
||||
sudo groupdel "${STORM_GROUP}" || true
|
||||
fi
|
||||
}
|
||||
|
||||
function configure_storm {
|
||||
if is_storm_enabled; then
|
||||
echo_summary "Configuring storm"
|
||||
sudo cp -f "${MONASCA_API_DIR}"/devstack/files/storm.yaml "${STORM_CURRENT_DIR}/conf/storm.yaml"
|
||||
sudo chown "${STORM_USER}":"${STORM_GROUP}" "${STORM_CURRENT_DIR}/conf/storm.yaml"
|
||||
sudo chmod 0644 "${STORM_CURRENT_DIR}/conf/storm.yaml"
|
||||
fi
|
||||
}
|
||||
|
||||
function install_storm {
|
||||
if is_storm_enabled; then
|
||||
echo_summary "Installing storm"
|
||||
_download_storm
|
||||
_setup_user_group
|
||||
_create_directories
|
||||
_install_storm
|
||||
fi
|
||||
}
|
||||
|
||||
function post_storm {
|
||||
if is_storm_enabled; then
|
||||
echo "Post configuring storm"
|
||||
# if inside the gate, make the visible there too
|
||||
if [ -n "${LOGDIR}" ]; then
|
||||
sudo ln -sfd "${STORM_LOG_DIR}/workers-artifacts" "${LOGDIR}/storm-workers"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# helpers
|
||||
|
||||
function _download_storm {
|
||||
local storm_tarball_url="${APACHE_MIRROR}storm/apache-storm-${STORM_VERSION}/${STORM_TARBALL}"
|
||||
local storm_dest
|
||||
|
||||
storm_dest=`get_extra_file ${storm_tarball_url}`
|
||||
|
||||
if [ "${storm_dest}" != "${STORM_TARBALL_DEST}" ]; then
|
||||
mv -f "${storm_dest}" "${STORM_TARBALL_DEST}"
|
||||
fi
|
||||
}
|
||||
|
||||
function _setup_user_group {
|
||||
sudo groupadd --system "${STORM_GROUP}" || true
|
||||
sudo useradd --system -g "${STORM_GROUP}" "${STORM_USER}" || true
|
||||
}
|
||||
|
||||
function _install_storm {
|
||||
# unpack (i.e. install) downloaded tarball
|
||||
sudo tar -xzf ${STORM_TARBALL_DEST} -C "${STORM_DIR}"
|
||||
|
||||
# link the versioned folder to more suitable one
|
||||
sudo ln -sfd "${STORM_DIR}/apache-storm-${STORM_VERSION}" "${STORM_CURRENT_DIR}"
|
||||
|
||||
# make them visible in standard location
|
||||
sudo ln -sfd "${STORM_LOG_DIR}" "${STORM_CURRENT_DIR}/logs"
|
||||
}
|
||||
|
||||
function _create_directories {
|
||||
for dir in "${STORM_DIR}" "${STORM_WORK_DIR}" "${STORM_LOG_DIR}"; do
|
||||
if [ ! -d "${dir}" ]; then
|
||||
sudo mkdir -p "${dir}" || true
|
||||
fi
|
||||
sudo chown "${STORM_USER}":"${STORM_GROUP}" "${dir}"
|
||||
sudo chmod 0775 "${dir}"
|
||||
done
|
||||
}
|
||||
|
||||
# helpers
|
||||
|
||||
$_XTRACE_STORM
|
|
@ -52,6 +52,7 @@ source ${MONASCA_API_DIR}/devstack/lib/notification.sh
|
|||
source ${MONASCA_API_DIR}/devstack/lib/profile.sh
|
||||
source ${MONASCA_API_DIR}/devstack/lib/client.sh
|
||||
source ${MONASCA_API_DIR}/devstack/lib/persister.sh
|
||||
source ${MONASCA_API_DIR}/devstack/lib/storm.sh
|
||||
# source lib/*
|
||||
|
||||
# Set default implementations to python
|
||||
|
@ -103,10 +104,7 @@ function pre_install_monasca {
|
|||
install_gate_config_holder
|
||||
install_kafka
|
||||
install_zookeeper
|
||||
|
||||
if is_service_enabled monasca-storm; then
|
||||
install_storm
|
||||
fi
|
||||
install_storm
|
||||
|
||||
install_monasca_virtual_env
|
||||
install_monasca_$MONASCA_METRICS_DB
|
||||
|
@ -123,7 +121,7 @@ function install_monasca {
|
|||
stack_install_service monasca-notification
|
||||
|
||||
if is_service_enabled monasca-thresh; then
|
||||
if ! is_service_enabled monasca-storm; then
|
||||
if ! is_storm_enabled; then
|
||||
die "monasca-thresh requires monasca-storm service to be enabled"
|
||||
fi
|
||||
install_monasca_thresh
|
||||
|
@ -146,6 +144,7 @@ function configure_monasca {
|
|||
#(trebskit) Installing should happen in post-config phase
|
||||
# at this point databases is already configured
|
||||
install_schema
|
||||
configure_storm
|
||||
configure_ui
|
||||
configure_monasca_api
|
||||
configure_monasca-notification
|
||||
|
@ -167,9 +166,11 @@ function extra_monasca {
|
|||
fi
|
||||
|
||||
start_monasca_services
|
||||
post_storm
|
||||
}
|
||||
|
||||
function start_monasca_services {
|
||||
start_storm
|
||||
if is_service_enabled monasca-api; then
|
||||
start_monasca_api
|
||||
fi
|
||||
|
@ -194,10 +195,7 @@ function unstack_monasca {
|
|||
|
||||
stop_service monasca-thresh || true
|
||||
|
||||
stop_service storm-supervisor || true
|
||||
|
||||
stop_service storm-nimbus || true
|
||||
|
||||
stop_storm
|
||||
stop_monasca-notification
|
||||
stop_monasca-persister
|
||||
stop_monasca_api
|
||||
|
@ -232,9 +230,7 @@ function clean_monasca {
|
|||
if is_service_enabled monasca-thresh; then
|
||||
clean_monasca_thresh
|
||||
fi
|
||||
if is_service_enabled monasca-storm; then
|
||||
clean_storm
|
||||
fi
|
||||
clean_storm
|
||||
if is_service_enabled monasca-api; then
|
||||
clean_monasca_api_$MONASCA_API_IMPLEMENTATION_LANG
|
||||
fi
|
||||
|
@ -924,104 +920,6 @@ function configure_monasca_api {
|
|||
#NOTE(basiaka) Refactor of monasca-api in Java version will be handled in another change
|
||||
}
|
||||
|
||||
function install_storm {
|
||||
|
||||
echo_summary "Install Monasca Storm"
|
||||
|
||||
local storm_tarball=apache-storm-${STORM_VERSION}.tar.gz
|
||||
local storm_tarball_url=${APACHE_MIRROR}storm/apache-storm-${STORM_VERSION}/${storm_tarball}
|
||||
|
||||
local storm_tarball_dest
|
||||
storm_tarball_dest=`get_extra_file ${storm_tarball_url}`
|
||||
|
||||
sudo groupadd --system storm || true
|
||||
|
||||
sudo useradd --system -g storm storm || true
|
||||
|
||||
sudo mkdir -p /opt/storm || true
|
||||
|
||||
sudo chown storm:storm /opt/storm
|
||||
|
||||
sudo chmod 0755 /opt/storm
|
||||
|
||||
sudo tar -xzf ${storm_tarball_dest} -C /opt/storm
|
||||
|
||||
sudo ln -sf /opt/storm/apache-storm-${STORM_VERSION} /opt/storm/current
|
||||
|
||||
sudo mkdir /var/storm || true
|
||||
|
||||
sudo chown storm:storm /var/storm
|
||||
|
||||
sudo chmod 0775 /var/storm
|
||||
|
||||
sudo mkdir /var/log/storm || true
|
||||
|
||||
sudo chown storm:storm /var/log/storm
|
||||
|
||||
sudo chmod 0775 /var/log/storm
|
||||
|
||||
sudo ln -sf /var/log/storm /opt/storm/current/logs
|
||||
|
||||
sudo cp -f "${MONASCA_API_DIR}"/devstack/files/storm/storm.yaml /opt/storm/apache-storm-${STORM_VERSION}/conf/storm.yaml
|
||||
|
||||
sudo chown storm:storm /opt/storm/apache-storm-${STORM_VERSION}/conf/storm.yaml
|
||||
|
||||
sudo chmod 0644 /opt/storm/apache-storm-${STORM_VERSION}/conf/storm.yaml
|
||||
|
||||
sudo cp -f "${MONASCA_API_DIR}"/devstack/files/storm/storm-nimbus.service /etc/systemd/system/storm-nimbus.service
|
||||
|
||||
sudo chown root:root /etc/systemd/system/storm-nimbus.service
|
||||
|
||||
sudo chmod 0644 /etc/systemd/system/storm-nimbus.service
|
||||
|
||||
sudo cp -f "${MONASCA_API_DIR}"/devstack/files/storm/storm-supervisor.service /etc/systemd/system/storm-supervisor.service
|
||||
|
||||
sudo chown root:root /etc/systemd/system/storm-supervisor.service
|
||||
|
||||
sudo chmod 0644 /etc/systemd/system/storm-supervisor.service
|
||||
|
||||
sudo systemctl enable storm-nimbus
|
||||
|
||||
sudo systemctl enable storm-supervisor
|
||||
|
||||
sudo systemctl start storm-nimbus || sudo systemctl restart storm-nimbus
|
||||
|
||||
sudo systemctl start storm-supervisor || sudo systemctl restart storm-supervisor
|
||||
|
||||
}
|
||||
|
||||
function clean_storm {
|
||||
|
||||
echo_summary "Clean Monasca Storm"
|
||||
|
||||
sudo systemctl disable storm-supervisor
|
||||
|
||||
sudo systemctl disable storm-nimbus
|
||||
|
||||
sudo rm /etc/systemd/system/storm-supervisor.service
|
||||
|
||||
sudo rm /etc/systemd/system/storm-nimbus.service
|
||||
|
||||
sudo rm /opt/storm/apache-storm-${STORM_VERSION}/conf/storm.yaml
|
||||
|
||||
sudo unlink /opt/storm/current/logs
|
||||
|
||||
sudo rm -rf /var/storm
|
||||
|
||||
sudo rm -rf /var/log/storm
|
||||
|
||||
sudo userdel storm || true
|
||||
|
||||
sudo groupdel storm || true
|
||||
|
||||
sudo unlink /opt/storm/current
|
||||
|
||||
sudo rm -rf /opt/storm
|
||||
|
||||
sudo rm ${FILES}/apache-storm-${STORM_VERSION}.tar.gz
|
||||
|
||||
}
|
||||
|
||||
function install_monasca_thresh {
|
||||
|
||||
echo_summary "Install Monasca monasca_thresh"
|
||||
|
|
|
@ -52,6 +52,8 @@ enable_service monasca-influxdb
|
|||
|
||||
# Apache Storm
|
||||
enable_service monasca-storm
|
||||
enable_service monasca-storm-nimbus
|
||||
enable_service monasca-storm-supervisor
|
||||
|
||||
# monasca-kafka depends on monasca-zookeeper
|
||||
enable_service monasca-kafka
|
||||
|
|
Loading…
Reference in New Issue