HEX
Server: nginx/1.22.1
System: Linux VM-16-9-centos 3.10.0-1160.99.1.el7.x86_64 #1 SMP Wed Sep 13 14:19:20 UTC 2023 x86_64
User: www (1001)
PHP: 7.3.31
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: //etc/rc5.d/S56redis
#!/bin/sh
# chkconfig: 2345 56 26
# description: Redis Service

### BEGIN INIT INFO
# Provides:          Redis
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts Redis
# Description:       starts the BT-Web
### END INIT INFO

# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.
#pkill -9 redis-server
ulimit -n 10240
CONF="/www/server/redis/redis.conf"
REDIS_PORT=$(cat $CONF |grep port|grep -v '#'|awk '{print $2}')
REDIS_PASS=$(cat $CONF |grep requirepass|grep -v '#'|awk '{print $2}')
REDIS_HOST=$(cat $CONF |grep bind|grep -v '#'|awk '{print $2}')
if [ "$REDIS_PASS" != "" ];then
	REDIS_PASS=" -a $REDIS_PASS"
fi
if [ -f "/www/server/redis/start.pl" ];then
	STAR_PORT=$(cat /www/server/redis/start.pl)
else
	STAR_PORT="6379"
fi
EXEC=/www/server/redis/src/redis-server
CLIEXEC="/www/server/redis/src/redis-cli -h ${REDIS_HOST} -p ${STAR_PORT}${REDIS_PASS}"
PIDFILE=/www/server/redis/redis.pid

redis_start(){
	if [ -f "/www/server/redis/redis.pid" ]; then
		ps -p $(cat ${PIDFILE}) > /dev/null 2>&1
		if [ $? -ne "0" ]; then
			rm -f ${PIDFILE}
		else
			echo "redis is running! ($(cat ${PIDFILE}))"
			exit 0
		fi
	fi
	echo "Starting redis server..."
	sudo -u redis $EXEC $CONF
	echo ${REDIS_PORT} > /www/server/redis/start.pl
	echo "Starting redis success!"
}
redis_status(){
	if [ -f "/www/server/redis/redis.pid" ]; then
		ps -p $(cat ${PIDFILE}) > /dev/null 2>&1
		if [ $? -ne "0" ]; then
			echo "Redis is not running, buy pid file is exits ${PIDFILE}"
			exit 1
		else
			echo "redis is running! ($(cat ${PIDFILE}))"
			exit 0
		fi
	else
		echo "redis is stopped"
		exit 0
	fi
}
redis_stop(){
	echo "Stopping ..."
	$CLIEXEC shutdown
	sleep 1
	if [ -f "/www/server/redis/redis.pid" ];then
		kill -9 $(cat /www/server/redis/redis.pid)
	fi
	rm -f ${PIDFILE}
	echo "Redis stopped"
}

case "$1" in
	start)
		redis_start
		;;
	stop)
		redis_stop
		;;
	status)
		redis_status
		;;
	restart|reload)
		redis_stop
		sleep 0.3
		redis_start
		;;
	*)
		echo "Please use start or stop as first argument"
		;;
esac