more test and vagrant for nginx checks

This commit is contained in:
Olof hagsand 2020-11-25 19:48:42 +01:00
parent 4f5b0178cc
commit f69daf773e
5 changed files with 38 additions and 27 deletions

View file

@ -161,7 +161,11 @@ pidfile_zapold(pid_t pid)
clicon_log(LOG_NOTICE, "Killing old daemon with pid: %d", pid);
killpg(pid, SIGTERM);
kill(pid, SIGTERM);
sleep(1); /* check again */
/* Need to sleep process properly and then check again */
if (usleep(100000) < 0){
clicon_err(OE_UNIX, errno, "usleep");
return -1;
}
if ((kill (pid, 0)) != 0 && errno == ESRCH) /* Nothing there */
;
else{ /* problem: couldnt kill it */

View file

@ -41,26 +41,29 @@ if [ -f ./config.sh ]; then
fi
fi
: ${SKIPLIST:=false}
# Sanity nginx running on systemd platforms
if systemctl > /dev/null 2>&1 ; then
# even if systemd exists, nginx may be started in other ways
nginxactive=$(systemctl show nginx |grep ActiveState=active)
if [ "${WITH_RESTCONF}" = "fcgi" ]; then
if [ -z "$nginxactive" -a ! -f /var/run/nginx.pid ]; then
echo -e "\e[31m\nwith-restconf=fcgi set but nginx not running, start with:"
echo "systemctl start nginx"
echo -e "\e[0m"
exit -1
if $NGINXCHECK; then
if systemctl > /dev/null 2>&1 ; then
# even if systemd exists, nginx may be started in other ways
nginxactive=$(systemctl show nginx |grep ActiveState=active)
if [ "${WITH_RESTCONF}" = "fcgi" ]; then
if [ -z "$nginxactive" -a ! -f /var/run/nginx.pid ]; then
echo -e "\e[31m\nwith-restconf=fcgi set but nginx not running, start with:"
echo "systemctl start nginx"
echo -e "\e[0m"
exit -1
fi
else
if [ -n "$nginxactive" -o -f /var/run/nginx.pid ]; then
echo -e "\e[31m\nwith-restconf=fcgi not set but nginx running, stop with:"
echo "systemctl stop nginx"
echo -e "\e[0m"
exit -1
fi
fi
else
if [ -n "$nginxactive" -o -f /var/run/nginx.pid ]; then
echo -e "\e[31m\nwith-restconf=fcgi not set but nginx running, stop with:"
echo "systemctl stop nginx"
echo -e "\e[0m"
exit -1
fi
fi
fi # systemctl
fi # systemctl
fi
# Test number from start
: ${testnr:=0}
@ -119,10 +122,10 @@ else
fi
# Multiplication factor to sleep less than whole seconds
DEMSLEEP=.5
DEMSLEEP=.2
# DEMWAIT is expressed in seconds, but really * DEMSLEEP
let DEMLOOP=2*DEMWAIT
let DEMLOOP=5*DEMWAIT
# RESTCONF protocol, eg http or https
: ${RCPROTO:=http}

View file

@ -22,5 +22,9 @@
# Some restconf tests can run IPv6, but its complicated because:
# - docker by default does not run IPv6
# - for fcgi nginx needs to be configured properly (shouldnt be a problem)
#IPv6=false
# Check sanity between --with-restconf setting and if nginx is started by systemd or not
# This check is optional because some installs, such as vagrant make a non-systemd/direct
# start
#NGINXCHECK=false

View file

@ -164,9 +164,11 @@ if [ $BE -ne 0 ]; then
fi
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
new "wait backend"
wait_backend
fi
new "waiting"
wait_backend
if [ $RC -ne 0 ]; then
@ -176,7 +178,7 @@ if [ $RC -ne 0 ]; then
new "start restconf daemon"
start_restconf -f $cfg
new "waiting"
new "wait restconf"
wait_restconf
fi

View file

@ -84,8 +84,6 @@ cat<<'EOF' > $dir/startnginx.sh
sudo sh -c ' echo 'nginx_enable="YES"' >> /etc/rc.conf'
fi
sudo /usr/local/etc/rc.d/nginx restart
elif systemctl > /dev/null 2>&1 ; then
sudo systemctl start nginx
else
sudo pkill nginx
nginxbin=$(sudo which nginx)