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

Answers


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.


Need Your Help

django app creates auth.user and app user at same time and stores auth.user_id in app.user

django-admin django-forms django-views django-authentication

I have an app that adds a user to the system via auth.user and the app. On save I want to create the user and then get the auth.user.id and add that to a team_user.id.

Registry: find and replace part of a path in a batch file

batch-file replace registry

I need to find and replace a specific part of a value in any key below HKEY_current_user.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.