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); clicon_log(LOG_NOTICE, "Killing old daemon with pid: %d", pid);
killpg(pid, SIGTERM); killpg(pid, SIGTERM);
kill(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 */ if ((kill (pid, 0)) != 0 && errno == ESRCH) /* Nothing there */
; ;
else{ /* problem: couldnt kill it */ else{ /* problem: couldnt kill it */

View file

@ -41,8 +41,10 @@ if [ -f ./config.sh ]; then
fi fi
fi fi
: ${SKIPLIST:=false}
# Sanity nginx running on systemd platforms # Sanity nginx running on systemd platforms
if systemctl > /dev/null 2>&1 ; then if $NGINXCHECK; then
if systemctl > /dev/null 2>&1 ; then
# even if systemd exists, nginx may be started in other ways # even if systemd exists, nginx may be started in other ways
nginxactive=$(systemctl show nginx |grep ActiveState=active) nginxactive=$(systemctl show nginx |grep ActiveState=active)
if [ "${WITH_RESTCONF}" = "fcgi" ]; then if [ "${WITH_RESTCONF}" = "fcgi" ]; then
@ -60,7 +62,8 @@ if systemctl > /dev/null 2>&1 ; then
exit -1 exit -1
fi fi
fi fi
fi # systemctl fi # systemctl
fi
# Test number from start # Test number from start
: ${testnr:=0} : ${testnr:=0}
@ -119,10 +122,10 @@ else
fi fi
# Multiplication factor to sleep less than whole seconds # Multiplication factor to sleep less than whole seconds
DEMSLEEP=.5 DEMSLEEP=.2
# DEMWAIT is expressed in seconds, but really * DEMSLEEP # DEMWAIT is expressed in seconds, but really * DEMSLEEP
let DEMLOOP=2*DEMWAIT let DEMLOOP=5*DEMWAIT
# RESTCONF protocol, eg http or https # RESTCONF protocol, eg http or https
: ${RCPROTO:=http} : ${RCPROTO:=http}

View file

@ -22,5 +22,9 @@
# Some restconf tests can run IPv6, but its complicated because: # Some restconf tests can run IPv6, but its complicated because:
# - docker by default does not run IPv6 # - docker by default does not run IPv6
# - for fcgi nginx needs to be configured properly (shouldnt be a problem)
#IPv6=false #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 fi
new "start backend -s init -f $cfg" new "start backend -s init -f $cfg"
start_backend -s init -f $cfg start_backend -s init -f $cfg
new "wait backend"
wait_backend
fi fi
new "waiting"
wait_backend
if [ $RC -ne 0 ]; then if [ $RC -ne 0 ]; then
@ -176,7 +178,7 @@ if [ $RC -ne 0 ]; then
new "start restconf daemon" new "start restconf daemon"
start_restconf -f $cfg start_restconf -f $cfg
new "waiting" new "wait restconf"
wait_restconf wait_restconf
fi fi

View file

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