Call to restart script from CGI not fully restarting
I'm trying to restart the Boa web server from inside a CGI script written in C. This is on a ucLinux system. The call to system("/etc/init.d/boa.sh restart") runs successfully and I see from the logs that Boa is stopped, but it is never started. Running boa.sh restart from the CLI does work OK. The boa.sh script is shown below. Any ideas as to why it's not fully restarting? Note that the CGI script itself is running within Boa.
NAME=boa PROG=/bin/boa OPTIONS="-c /etc/" LOCKFILE=/var/lock/boa STDLOGFILE=/var/log/boaerrlog.log case "$1" in start) echo -n $"Starting $NAME: " boa $OPTIONS > /dev/null 2>&1 & # boa $OPTIONS >$STDOUTFILE 2>&1 & touch $LOCKFILE echo "OK" ;; stop) echo -n $"Stopping $NAME: " kill -TERM `pidof $NAME` > /dev/null 2>&1 rm -f $LOCKFILE $PIDFILE > /dev/null 2>&1 echo "OK" ;; restart) $0 stop $0 start ;; status) echo "running" ;; esac
Information gathered in a chat.
The process that is being restarted through the system call in the CGI is actually being served by the same process. This does not work as the term signal likely is killing all process in the tree including the restarted boa process.
An alternative is to have a second instance of boa running that can restart the production instance. While the production instance can restart the second instance used to restart the production instance.