install.sh: add supervisor support
Bring supervisor support from dist/docker to install.sh, make it installable from relocatable package. This enables to use supervisor with nonroot / offline environment, and also make relocatable package able to run in Docker environment. Related #8849 Closes #8918
This commit is contained in:
7
dist/common/supervisor/scylla-jmx.sh
vendored
Executable file
7
dist/common/supervisor/scylla-jmx.sh
vendored
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
. $(dirname "$0")/scylla_util.sh
|
||||
|
||||
. "$sysconfdir"/scylla-jmx
|
||||
|
||||
exec "$scylladir"/jmx/scylla-jmx $SCYLLA_JMX_PORT $SCYLLA_API_PORT $SCYLLA_API_ADDR $SCYLLA_JMX_ADDR $SCYLLA_JMX_FILE $SCYLLA_JMX_LOCAL $SCYLLA_JMX_REMOTE $SCYLLA_JMX_DEBUG
|
||||
7
dist/common/supervisor/scylla-node-exporter.sh
vendored
Executable file
7
dist/common/supervisor/scylla-node-exporter.sh
vendored
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
. $(dirname "$0")/scylla_util.sh
|
||||
|
||||
. "$sysconfdir"/scylla-node-exporter
|
||||
|
||||
exec "$scylladir"/node_exporter/node_exporter $SCYLLA_NODE_EXPORTER_ARGS
|
||||
14
dist/common/supervisor/scylla-server.sh
vendored
Executable file
14
dist/common/supervisor/scylla-server.sh
vendored
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
. $(dirname "$0")/scylla_util.sh
|
||||
|
||||
. "$sysconfdir"/scylla-server
|
||||
|
||||
for f in "$etcdir"/scylla.d/*.conf; do
|
||||
. "$f"
|
||||
done
|
||||
|
||||
if is_privileged; then
|
||||
"$scriptsdir"/scylla_prepare
|
||||
fi
|
||||
execsudo /usr/bin/env SCYLLA_HOME=$SCYLLA_HOME SCYLLA_CONF=$SCYLLA_CONF "$bindir"/scylla $SCYLLA_ARGS $SEASTAR_IO $DEV_MODE $CPUSET $SCYLLA_DOCKER_ARGS
|
||||
32
dist/common/supervisor/scylla_util.sh
vendored
Executable file
32
dist/common/supervisor/scylla_util.sh
vendored
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
scylladir="$(readlink -f $(dirname "$0")/..)"
|
||||
|
||||
is_nonroot() {
|
||||
[ -f "$scylladir"/SCYLLA-NONROOT-FILE ]
|
||||
}
|
||||
|
||||
is_privileged() {
|
||||
[ ${EUID:-${UID}} = 0 ]
|
||||
}
|
||||
|
||||
execsudo() {
|
||||
if is_nonroot; then
|
||||
exec "$@"
|
||||
else
|
||||
exec sudo -u scylla -g scylla "$@"
|
||||
fi
|
||||
}
|
||||
scriptsdir="$scylladir/scripts"
|
||||
# scylla_sysconfdir.py is compatible both on python and bash
|
||||
. "$scriptsdir"/scylla_sysconfdir.py
|
||||
if is_nonroot; then
|
||||
etcdir="$scylladir/etc"
|
||||
bindir="$scylladir/bin"
|
||||
sysconfdir="$scylladir/$SYSCONFDIR"
|
||||
else
|
||||
etcdir="/etc"
|
||||
bindir="/usr/bin"
|
||||
sysconfdir="$SYSCONFDIR"
|
||||
fi
|
||||
|
||||
84
install.sh
84
install.sh
@@ -40,6 +40,8 @@ Options:
|
||||
--sysconfdir /etc/sysconfig specify sysconfig directory name
|
||||
--packaging use install.sh for packaging
|
||||
--upgrade upgrade existing scylla installation (don't overwrite config files)
|
||||
--supervisor enable supervisor to manage scylla processes
|
||||
--supervisor-log-to-stdout logging to stdout on supervisor
|
||||
--help this helpful message
|
||||
EOF
|
||||
exit 1
|
||||
@@ -77,6 +79,8 @@ housekeeping=false
|
||||
nonroot=false
|
||||
packaging=false
|
||||
upgrade=false
|
||||
supervisor=false
|
||||
supervisor_log_to_stdout=false
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
@@ -112,6 +116,14 @@ while [ $# -gt 0 ]; do
|
||||
upgrade=true
|
||||
shift 1
|
||||
;;
|
||||
"--supervisor")
|
||||
supervisor=true
|
||||
shift 1
|
||||
;;
|
||||
"--supervisor-log-to-stdout")
|
||||
supervisor_log_to_stdout=true
|
||||
shift 1
|
||||
;;
|
||||
"--help")
|
||||
shift 1
|
||||
print_usage
|
||||
@@ -210,7 +222,38 @@ check_usermode_support() {
|
||||
[ -n "$user" ]
|
||||
}
|
||||
|
||||
if ! $packaging && [ ! -d /run/systemd/system/ ]; then
|
||||
. /etc/os-release
|
||||
|
||||
is_debian_variant() {
|
||||
[ "$ID_LIKE" = "debian" -o "$ID" = "debian" ]
|
||||
}
|
||||
|
||||
is_alpine() {
|
||||
[ "$ID" = "alpine" ]
|
||||
}
|
||||
|
||||
supervisor_dir() {
|
||||
local etcdir="$1"
|
||||
if is_debian_variant; then
|
||||
echo "$etcdir"/supervisor/conf.d
|
||||
elif is_alpine; then
|
||||
echo "$etcdir"/supervisor.d
|
||||
else
|
||||
echo "$etcdir"/supervisord.d
|
||||
fi
|
||||
}
|
||||
|
||||
supervisor_conf() {
|
||||
local etcdir="$1"
|
||||
local service="$2"
|
||||
if is_debian_variant; then
|
||||
echo `supervisor_dir "$etcdir"`/"$service".conf
|
||||
else
|
||||
echo `supervisor_dir "$etcdir"`/"$service".ini
|
||||
fi
|
||||
}
|
||||
|
||||
if ! $packaging && [ ! -d /run/systemd/system/ ] && ! $supervisor; then
|
||||
echo "systemd is not detected, unsupported distribution."
|
||||
exit 1
|
||||
fi
|
||||
@@ -363,6 +406,10 @@ cp -r tools/scyllatop/* "$rprefix"/scyllatop
|
||||
install -d -m755 -d "$rprefix"/scripts
|
||||
cp -r dist/common/scripts/* "$rprefix"/scripts
|
||||
ln -srf "$rprefix/scyllatop/scyllatop.py" "$rprefix/bin/scyllatop"
|
||||
if $supervisor; then
|
||||
install -d -m755 "$rprefix"/supervisor
|
||||
install -m755 dist/common/supervisor/* -Dt "$rprefix"/supervisor
|
||||
fi
|
||||
|
||||
SBINFILES=$(cd dist/common/scripts/; ls scylla_*setup node_health_check scylla_ec2_check scylla_kernel_check)
|
||||
SBINFILES+=" $(cd seastar/scripts; ls seastar-cpu-map.sh)"
|
||||
@@ -470,21 +517,48 @@ for i in seastar/scripts/perftune.py seastar/scripts/seastar-addr2line; do
|
||||
done
|
||||
relocate_python3 "$rprefix"/scyllatop tools/scyllatop/scyllatop.py
|
||||
|
||||
if $supervisor; then
|
||||
install -d -m755 `supervisor_dir $retc`
|
||||
for service in scylla-server scylla-jmx scylla-node-exporter; do
|
||||
cat << EOS > `supervisor_conf $retc $service`
|
||||
[program:$service]
|
||||
directory=$rprefix
|
||||
command=/bin/bash -c './supervisor/$service.sh'
|
||||
EOS
|
||||
if [ "$service" != "scylla-server" ]; then
|
||||
cat << EOS >> `supervisor_conf $retc $service`
|
||||
user=scylla
|
||||
EOS
|
||||
fi
|
||||
if $supervisor_log_to_stdout; then
|
||||
cat << EOS >> `supervisor_conf $retc $service`
|
||||
stdout_logfile=/dev/stdout
|
||||
stdout_logfile_maxbytes=0
|
||||
stderr_logfile=/dev/stderr
|
||||
stderr_logfile_maxbytes=0
|
||||
EOS
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if $nonroot; then
|
||||
sed -i -e "s#/var/lib/scylla#$rprefix#g" $rsysconfdir/scylla-server
|
||||
sed -i -e "s#/etc/scylla#$retc/scylla#g" $rsysconfdir/scylla-server
|
||||
sed -i -e "s#^SCYLLA_ARGS=\"#SCYLLA_ARGS=\"--workdir $rprefix #g" $rsysconfdir/scylla-server
|
||||
if [ ! -d /var/log/journal ]; then
|
||||
if [ ! -d /var/log/journal ] || $supervisor_log_to_stdout; then
|
||||
sed -i -e "s#--log-to-stdout 0#--log-to-stdout 1#g" $rsysconfdir/scylla-server
|
||||
fi
|
||||
# nonroot install is also 'offline install'
|
||||
touch $rprefix/SCYLLA-OFFLINE-FILE
|
||||
touch $rprefix/SCYLLA-NONROOT-FILE
|
||||
if ! $packaging && check_usermode_support; then
|
||||
if ! $supervisor && ! $packaging && check_usermode_support; then
|
||||
systemctl --user daemon-reload
|
||||
fi
|
||||
echo "Scylla non-root install completed."
|
||||
elif ! $packaging; then
|
||||
if $supervisor_log_to_stdout; then
|
||||
sed -i -e "s#--log-to-stdout 0#--log-to-stdout 1#g" $rsysconfdir/scylla-server
|
||||
fi
|
||||
# run install.sh without --packaging is 'offline install'
|
||||
touch $rprefix/SCYLLA-OFFLINE-FILE
|
||||
nousr=
|
||||
@@ -508,6 +582,8 @@ elif ! $packaging; then
|
||||
# ignore error since some kernel may not have specified parameter
|
||||
sysctl -p "$rusr"/lib/sysctl.d/"$bn" || :
|
||||
done
|
||||
$rprefix/scripts/scylla_post_install.sh
|
||||
if ! $supervisor; then
|
||||
$rprefix/scripts/scylla_post_install.sh
|
||||
fi
|
||||
echo "Scylla offline install completed."
|
||||
fi
|
||||
|
||||
@@ -38,6 +38,8 @@ Options:
|
||||
--housekeeping enable housekeeping service
|
||||
--nonroot install Scylla without required root priviledge
|
||||
--sysconfdir /etc/sysconfig specify sysconfig directory name
|
||||
--supervisor enable supervisor to manage scylla processes
|
||||
--supervisor-log-to-stdout logging to stdout on supervisor
|
||||
--help this helpful message
|
||||
EOF
|
||||
exit 1
|
||||
@@ -51,6 +53,8 @@ check_usermode_support() {
|
||||
root=/
|
||||
housekeeping=false
|
||||
nonroot=false
|
||||
supervisor=false
|
||||
supervisor_log_to_stdout=false
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
@@ -78,6 +82,14 @@ while [ $# -gt 0 ]; do
|
||||
sysconfdir="$2"
|
||||
shift 2
|
||||
;;
|
||||
"--supervisor")
|
||||
supervisor=true
|
||||
shift 1
|
||||
;;
|
||||
"--supervisor-log-to-stdout")
|
||||
supervisor_log_to_stdout=true
|
||||
shift 1
|
||||
;;
|
||||
"--help")
|
||||
shift 1
|
||||
print_usage
|
||||
@@ -88,7 +100,7 @@ while [ $# -gt 0 ]; do
|
||||
esac
|
||||
done
|
||||
|
||||
if [ ! -d /run/systemd/system/ ]; then
|
||||
if [ ! -d /run/systemd/system/ ] && ! $supervisor; then
|
||||
echo "systemd is not detected, unsupported distribution."
|
||||
exit 1
|
||||
fi
|
||||
@@ -141,6 +153,13 @@ if $nonroot; then
|
||||
scylla_args+=(--nonroot)
|
||||
args+=(--nonroot)
|
||||
fi
|
||||
if $supervisor; then
|
||||
scylla_args+=(--supervisor)
|
||||
args+=(--supervisor)
|
||||
fi
|
||||
if $supervisor_log_to_stdout; then
|
||||
scylla_args+=(--supervisor-log-to-stdout)
|
||||
fi
|
||||
|
||||
(cd $(readlink -f scylla); ./install.sh --root "$root" --prefix "$prefix" --python3 "$python3" --sysconfdir "$sysconfdir" ${scylla_args[@]})
|
||||
|
||||
@@ -152,6 +171,6 @@ fi
|
||||
|
||||
install -m755 uninstall.sh -Dt "$rprefix"
|
||||
|
||||
if $nonroot && ! check_usermode_support; then
|
||||
if ! $supervisor && $nonroot && ! check_usermode_support; then
|
||||
echo "WARNING: This distribution does not support systemd user mode, please configure and launch Scylla manually."
|
||||
fi
|
||||
|
||||
@@ -73,6 +73,7 @@ rm -fv "$rsystemd"/{scylla-*.service,scylla-*.timer,scylla-*.slice}
|
||||
if ! $nonroot; then
|
||||
rm -rfv "$retc"/systemd/system/scylla-*.service.d
|
||||
rm -fv "$retc"/bash_completion.d/nodetool-completion
|
||||
rm -fv "$retc"/supervisord.d/scylla-*.ini
|
||||
rm -fv "$rusr"/lib/sysctl.d/99-scylla-*.conf
|
||||
rm -fv "$rusr"/bin/{scylla,iotune,scyllatop}
|
||||
rm -fv "$rusr"/sbin/{scylla_*setup,node_exporter_install,node_health_check,scylla_ec2_check,scylla_kernel_check}
|
||||
|
||||
Reference in New Issue
Block a user