summaryrefslogtreecommitdiffstats
path: root/meta-oe
diff options
context:
space:
mode:
authorStefan Ghinea <stefan.ghinea@windriver.com>2023-03-18 02:16:33 +0200
committerKhem Raj <raj.khem@gmail.com>2023-03-18 09:36:49 -0700
commitedea484f2dee3e4d7101b14f4a22d28be0291aa0 (patch)
tree4c5a3f2381ede33bd9fb4fb7f66f67ef8aa11ec4 /meta-oe
parent880bd38370b76245d8cf63a6118bbc1bd6e535cf (diff)
downloadmeta-openembedded-edea484f2dee3e4d7101b14f4a22d28be0291aa0.tar.gz
redis: fix service redis-server restart not working under sysvinit
Under sysvinit when trying to restart redis-server using service redis-server restart two calls are made to start-stop-daemon, first with the --stop argument and then with --start argument consecutively. Because the process doesn't immediately terminate when start-stop-daemon --stop is called, the next call to start-stop-daemon --start finds the process still running and does not attempt to start another one. This leads to only a stop of the redis-server process when a restart is requested. This behavior affects all redis versions using sysvinit only. This can be fixed by using the --retry <timeout/schedule> argument with start-stop-daemon --stop in order for the call to block until the process terminates so that start-stop-daemon --start will attempt to start a new process. Unfortunately the --retry argument works only in the implementation of start-stop-daemon provided by dpkg package and is ignored in the implementation provided by busybox package. A repeated check if the process is still running and another try with another signal after a timeout will effectively simulate a stop with --retry=TERM/5/KILL/5 schedule. Signed-off-by: Stefan Ghinea <stefan.ghinea@windriver.com> Signed-off-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'meta-oe')
-rwxr-xr-xmeta-oe/recipes-extended/redis/redis-7/init-redis-server31
-rwxr-xr-xmeta-oe/recipes-extended/redis/redis/init-redis-server31
2 files changed, 62 insertions, 0 deletions
diff --git a/meta-oe/recipes-extended/redis/redis-7/init-redis-server b/meta-oe/recipes-extended/redis/redis-7/init-redis-server
index 6014d70c0..c5f335f57 100755
--- a/meta-oe/recipes-extended/redis/redis-7/init-redis-server
+++ b/meta-oe/recipes-extended/redis/redis-7/init-redis-server
@@ -27,6 +27,37 @@ case "$1" in
27 restart) 27 restart)
28 echo "Stopping redis-server..." 28 echo "Stopping redis-server..."
29 start-stop-daemon --stop --quiet --exec /usr/bin/redis-server 29 start-stop-daemon --stop --quiet --exec /usr/bin/redis-server
30
31 # Since busybox implementation ignores --retry arguments repeatedly check
32 # if the process is still running and try another signal after a timeout,
33 # efectively simulating a stop with --retry=TERM/5/KILL/5 schedule.
34 waitAfterTerm=5000000 # us / 5000 ms / 5 s
35 waitAfterKill=5000000 # us / 5000 ms / 5 s
36 waitStep=100000 # us / 100 ms / 0.1 s
37 waited=0
38 start-stop-daemon --stop --test --quiet --exec /usr/bin/redis-server
39 processOff=$?
40 while [ $processOff -eq 0 ] && [ $waited -le $waitAfterTerm ] ; do
41 usleep ${waitStep}
42 ((waited+=${waitStep}))
43 start-stop-daemon --stop --test --quiet --exec /usr/bin/redis-server
44 processOff=$?
45 done
46 if [ $processOff -eq 0 ] ; then
47 start-stop-daemon --stop --signal KILL --exec /usr/bin/redis-server
48 start-stop-daemon --stop --test --quiet --exec /usr/bin/redis-server
49 processOff=$?
50 fi
51 waited=0
52 while [ $processOff -eq 0 ] && [ $waited -le $waitAfterKill ] ; do
53 usleep ${waitStep}
54 ((waited+=${waitStep}))
55 start-stop-daemon --stop --test --quiet --exec /usr/bin/redis-server
56 processOff=$?
57 done
58 # Here $processOff will indicate if waiting and retrying according to
59 # the schedule ended in a successfull stop or not.
60
30 echo "Starting redis-server..." 61 echo "Starting redis-server..."
31 start-stop-daemon --start --quiet --exec /usr/bin/redis-server -- $ARGS 62 start-stop-daemon --start --quiet --exec /usr/bin/redis-server -- $ARGS
32 ;; 63 ;;
diff --git a/meta-oe/recipes-extended/redis/redis/init-redis-server b/meta-oe/recipes-extended/redis/redis/init-redis-server
index 6014d70c0..c5f335f57 100755
--- a/meta-oe/recipes-extended/redis/redis/init-redis-server
+++ b/meta-oe/recipes-extended/redis/redis/init-redis-server
@@ -27,6 +27,37 @@ case "$1" in
27 restart) 27 restart)
28 echo "Stopping redis-server..." 28 echo "Stopping redis-server..."
29 start-stop-daemon --stop --quiet --exec /usr/bin/redis-server 29 start-stop-daemon --stop --quiet --exec /usr/bin/redis-server
30
31 # Since busybox implementation ignores --retry arguments repeatedly check
32 # if the process is still running and try another signal after a timeout,
33 # efectively simulating a stop with --retry=TERM/5/KILL/5 schedule.
34 waitAfterTerm=5000000 # us / 5000 ms / 5 s
35 waitAfterKill=5000000 # us / 5000 ms / 5 s
36 waitStep=100000 # us / 100 ms / 0.1 s
37 waited=0
38 start-stop-daemon --stop --test --quiet --exec /usr/bin/redis-server
39 processOff=$?
40 while [ $processOff -eq 0 ] && [ $waited -le $waitAfterTerm ] ; do
41 usleep ${waitStep}
42 ((waited+=${waitStep}))
43 start-stop-daemon --stop --test --quiet --exec /usr/bin/redis-server
44 processOff=$?
45 done
46 if [ $processOff -eq 0 ] ; then
47 start-stop-daemon --stop --signal KILL --exec /usr/bin/redis-server
48 start-stop-daemon --stop --test --quiet --exec /usr/bin/redis-server
49 processOff=$?
50 fi
51 waited=0
52 while [ $processOff -eq 0 ] && [ $waited -le $waitAfterKill ] ; do
53 usleep ${waitStep}
54 ((waited+=${waitStep}))
55 start-stop-daemon --stop --test --quiet --exec /usr/bin/redis-server
56 processOff=$?
57 done
58 # Here $processOff will indicate if waiting and retrying according to
59 # the schedule ended in a successfull stop or not.
60
30 echo "Starting redis-server..." 61 echo "Starting redis-server..."
31 start-stop-daemon --start --quiet --exec /usr/bin/redis-server -- $ARGS 62 start-stop-daemon --start --quiet --exec /usr/bin/redis-server -- $ARGS
32 ;; 63 ;;