Webdav server does not stop

This is effectively same as WebDav constant errors after GC scipt

The issue seems to be that /seafile-server-latest/seafile.sh contains:

function check_component_running() {                                                 
    name=$1                                                                          
    cmd=$2                                                                                                                                                                                                                                                                                                                
    if pid=$(pgrep -f "$cmd" 2>/dev/null); then                                      
        echo "[$name] is running, pid $pid. You can stop it by: "                    
        echo                                                                         
        echo "        kill $pid"                                                     
        echo                                                                         
        echo "Stop it and try again."                                                
        echo                                                                         
        exit                                                                         
    fi                                                                               
}                                                                                    
                                                                                     
function validate_already_running () {                                               
    /-/
    check_component_running "seafdav" "wsgidav.server.server_cli"                    
    /-/
} 

function kill_all () {                                                                                                                                                                                                                                                                                                    
    /-/
    pkill -f  "wsgidav.server.server_cli"                                            
    /-/
}

When running pgrep, it does find the running processes:

$ pgrep -f  "wsgidav.server.server_cli"
162
164
166

Yet kill does nothing:

$ pkill -f  "wsgidav.server.server_cli"

This means when we run seafile.sh stop followed by seafile.sh start, we get following errors in log:

[seafdav] is running, pid 162
164
166. You can stop it by: 

        kill 162
164
166

Stop it and try again

and seafile no longer starts.

This leaves me to believe the stopping logic is faulty and needs fixing.
Running v11.0.12

It’s unclear what needs to happen for webdav service not to shut down successfully. If seafile is started and immediately stopped, then webdav appears to shut down as expected. Possibly reproduction requires:

  1. start seafile
  2. use webdav (e.g. sync some files via webdav client)
  3. stop seafile
  4. notice webdav processes still hanging

Looks like manually sending SIGHUP or SIGKILL does end with process finishing, but not sure whether it’s safe to do so:

$ pkill --signal SIGHUP -f "wsgidav.server.server_cli"

Controller appears to be SIGKILL-ing webdav, so not sure why it wouldn’t succeed.

Perhaps it sends signal to the main process alone and that doesn’t give chance to wsgidav to clean up child processes?

Edit: manually sent SIGTERM instead of sigkill to the parent PID, and that caused just one of the child processes to finish (not even the parent, only one of the children).

FYI asked about proper way of shutting down wsgidav in the project github.

Actually, for me, that’s exactly what is need to get everything working: WebDav constant errors after GC scipt - #5 by MajorP
So does this solution not work for you? Nevertheless, I think it’s no glorious chapter for Seafile that this bug still exists in the GC script.

Problem isn’t with the gc script. As mentioned above, the issue lies with how seafile.sh stop is killing the service, including webdav processes.

Opened gh issue under seafile project.