2010-01-11 10:15:54 +00:00
|
|
|
#!/bin/sh
|
2011-06-14 11:48:49 +00:00
|
|
|
#
|
2024-04-09 08:24:03 +00:00
|
|
|
# Simple server init.d script conceived to work on Linux systems
|
2011-06-14 11:48:49 +00:00
|
|
|
# as it does use of the /proc filesystem.
|
2010-01-11 10:15:54 +00:00
|
|
|
|
2018-03-26 09:29:16 +00:00
|
|
|
### BEGIN INIT INFO
|
2024-04-24 08:05:11 +00:00
|
|
|
# Provides: valkey_6379
|
2018-03-26 09:29:16 +00:00
|
|
|
# Default-Start: 2 3 4 5
|
|
|
|
# Default-Stop: 0 1 6
|
2024-04-24 08:05:11 +00:00
|
|
|
# Short-Description: Valkey data structure server
|
|
|
|
# Description: Valkey data structure server. See https://valkey.io
|
2018-03-26 09:29:16 +00:00
|
|
|
### END INIT INFO
|
|
|
|
|
2024-04-24 08:05:11 +00:00
|
|
|
VALKEYPORT=6379
|
|
|
|
EXEC=/usr/local/bin/valkey-server
|
|
|
|
CLIEXEC=/usr/local/bin/valkey-cli
|
2010-01-11 10:15:54 +00:00
|
|
|
|
2024-04-24 08:05:11 +00:00
|
|
|
PIDFILE=/var/run/valkey_${VALKEYPORT}.pid
|
|
|
|
CONF="/etc/valkey/${VALKEYPORT}.conf"
|
2010-01-11 10:15:54 +00:00
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
if [ -f $PIDFILE ]
|
|
|
|
then
|
2011-06-14 11:48:49 +00:00
|
|
|
echo "$PIDFILE exists, process is already running or crashed"
|
2010-01-11 10:15:54 +00:00
|
|
|
else
|
2024-04-24 08:05:11 +00:00
|
|
|
echo "Starting Valkey server..."
|
2010-01-11 10:15:54 +00:00
|
|
|
$EXEC $CONF
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
if [ ! -f $PIDFILE ]
|
|
|
|
then
|
2011-06-14 11:48:49 +00:00
|
|
|
echo "$PIDFILE does not exist, process is not running"
|
2010-01-11 10:15:54 +00:00
|
|
|
else
|
2011-06-14 11:48:49 +00:00
|
|
|
PID=$(cat $PIDFILE)
|
|
|
|
echo "Stopping ..."
|
2024-04-24 08:05:11 +00:00
|
|
|
$CLIEXEC -p $VALKEYPORT shutdown
|
2011-06-14 15:11:44 +00:00
|
|
|
while [ -x /proc/${PID} ]
|
2010-01-11 10:15:54 +00:00
|
|
|
do
|
2024-04-24 08:05:11 +00:00
|
|
|
echo "Waiting for Valkey to shutdown ..."
|
2010-01-11 10:15:54 +00:00
|
|
|
sleep 1
|
|
|
|
done
|
2024-04-24 08:05:11 +00:00
|
|
|
echo "Valkey stopped"
|
2010-01-11 10:15:54 +00:00
|
|
|
fi
|
|
|
|
;;
|
2011-06-14 11:48:49 +00:00
|
|
|
*)
|
|
|
|
echo "Please use start or stop as first argument"
|
|
|
|
;;
|
2010-01-11 10:15:54 +00:00
|
|
|
esac
|