Implement the logic in bin/stop-server

patch by Ling Mao; reviewed by Stefan Miklosovic and Brandon Williams for CASSANDRA-18838

Co-authored-by: Stefan Miklosovic <smiklosovic@apache.org>
This commit is contained in:
maoling 2023-10-18 12:49:14 +02:00 committed by Stefan Miklosovic
parent dc7234134c
commit f27c6c8e6e
No known key found for this signature in database
GPG Key ID: 32F35CB2F546D93E
3 changed files with 56 additions and 12 deletions

View File

@ -1,4 +1,5 @@
3.0.30 3.0.30
* Implement the logic in bin/stop-server (CASSANDRA-18838)
* Upgrade snappy-java to 1.1.10.4 (CASSANDRA-18878) * Upgrade snappy-java to 1.1.10.4 (CASSANDRA-18878)
* Add cqlshrc.sample and credentials.sample into Debian package (CASSANDRA-18818) * Add cqlshrc.sample and credentials.sample into Debian package (CASSANDRA-18818)
* Refactor validation logic in StorageService.rebuild (CASSANDRA-18803) * Refactor validation logic in StorageService.rebuild (CASSANDRA-18803)

View File

@ -1,3 +1,5 @@
#!/bin/sh
# Licensed to the Apache Software Foundation (ASF) under one # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file # or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information # distributed with this work for additional information
@ -14,18 +16,59 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
show_help()
{
echo "Usage: $0 [-p <pidfile>] | [-l] | [-e] | [-h]"
echo " -p <pidfile> Stop the process using the specified pidfile"
echo " -l Stop the process with the name like 'cassandra'"
echo " -e Stop the process with the name equal 'CassandraDaemon'"
echo " -h Show the help message"
}
echo "please read the stop-server script before use" kill_processes()
{
pids=$(pgrep -u "$(whoami)" -f "${1}")
if [ -n "$pids" ]; then
echo "$pids" | xargs kill -9
fi
}
if [ $# -eq 0 ]; then
show_help
exit 1
fi
case "$1" in
-p)
if [ -z "$2" ]; then
echo "missing pidfile argument after -p"
exit 1
fi
if [ ! -f "$2" ]; then
echo "pidfile $2 does not exist"
exit 1
fi
# if you are using the cassandra start script with -p, this # if you are using the cassandra start script with -p, this
# is the best way to stop: # is the best way to stop:
kill "$(cat "$2")"
# kill `cat <pidfile>` ;;
-l)
# you can run something like this, but
# otherwise, you can run something like this, but
# this is a shotgun approach and will kill other processes # this is a shotgun approach and will kill other processes
# with cassandra in their name or arguments too: # with cassandra in their name or arguments too:
kill_processes cassandra
;;
-e)
kill_processes org.apache.cassandra.service.CassandraDaemon
;;
-h)
show_help
exit 0
;;
*)
show_help
exit 1
;;
esac
# user=`whoami` exit 0
# pgrep -u $user -f cassandra | xargs kill -9

View File

@ -104,6 +104,7 @@ rm -f bin/*.bat
rm -f bin/*.orig rm -f bin/*.orig
rm -f bin/*.ps1 rm -f bin/*.ps1
rm -f bin/cassandra.in.sh rm -f bin/cassandra.in.sh
rm -f bin/stop-server
rm -f lib/sigar-bin/*winnt* # strip segfaults on dll.. rm -f lib/sigar-bin/*winnt* # strip segfaults on dll..
rm -f tools/bin/*.bat rm -f tools/bin/*.bat
rm -f tools/bin/cassandra.in.sh rm -f tools/bin/cassandra.in.sh
@ -154,7 +155,6 @@ exit 0
%attr(755,root,root) %{_bindir}/sstableupgrade %attr(755,root,root) %{_bindir}/sstableupgrade
%attr(755,root,root) %{_bindir}/sstableutil %attr(755,root,root) %{_bindir}/sstableutil
%attr(755,root,root) %{_bindir}/sstableverify %attr(755,root,root) %{_bindir}/sstableverify
%attr(755,root,root) %{_bindir}/stop-server
%attr(755,root,root) %{_sbindir}/cassandra %attr(755,root,root) %{_sbindir}/cassandra
%attr(755,root,root) /%{_sysconfdir}/rc.d/init.d/%{username} %attr(755,root,root) /%{_sysconfdir}/rc.d/init.d/%{username}
%{_sysconfdir}/default/%{username} %{_sysconfdir}/default/%{username}