Restart of lswsctrl doesn't load .htaccess changes

#1
Recently I've configured a second dedicated server for hosting WordPress sites for clients. I've got another one that's running for about 4 years.

Server 1: Almalinux 8 + DirectAdmin + OLS
Server 2: Almalinux 10 + DirectAdmin + OLS

Because we need a restart of the webserver after a change in .htaccess files, I'm using on both servers the exact same script, that's based on the well known cron job:
Code:
#!/bin/sh
#========================
# Description: this script checks if .htaccess files have been changed in order to restart the Open LiteSpeed webserver
# Environment: Almalinux, DirectAdmin (might need adjustments for other setups)
# Save the script in /root/scripts/ols-restart-check.sh and make sure you enter your own email address in the mail command.
# Usage: call this script in /etc/cron.d/openlitespeed_htaccess_scan with the following line:
# */3 * * * root /root/scripts/ols-restart-check.sh
#========================
changed_files=$(find /home/*/domains/*/public_html/ -maxdepth 2 -type f -newer /usr/local/lsws/cgid -name '.htaccess' 2>/dev/null)
if [ -n "$changed_files" ]; then
  echo "OpenLiteSpeed restarted due to the following changed .htaccess files:" > /tmp/ols_restart_info.txt
  echo "$changed_files" >> /tmp/ols_restart_info.txt
  /usr/local/lsws/bin/lswsctrl restart >> /tmp/ols_restart_info.txt 2>&1
  mail -s "OpenLiteSpeed Restart Notification" your-email@example.com < /tmp/ols_restart_info.txt
  rm /tmp/ols_restart_info.txt
fi
(src: https://codeberg.org/JosKlever/Server-Maintenance/src/branch/main/ols-restart-check.sh)

The script works and the output that I receive by email is the same for both servers, but I notice that on server 2 the htaccess changes are not processed.
I have to do a reload instead of a restart to process the new htaccess files/changes. Even though both restart and reload should have the same function, it apparently doesn't... But when I replace the "restart" by "reload" in the script, I get [ERROR] litespeed is not running. and this keeps going on until I change it back to "restart".

What could this be?
 
#3
Thanks! I've changed my script to test it and will see how it goes. In the meantime I have 2 questions about this:
  1. What's the difference between these two methods? I've seen a post that said it has to do with how lsws is started, but I would guess it's the same for both servers. Or isn't it?
  2. If restart and reload are the same, why do they behave differently?
 
#5
I haven't got Almalinux 10 yet, so I am not sure, but with CloudLinux 8 and 9, I also get [ERROR] litespeed is not running. randomly, even the OLS service is still ON / ready. Again, only randomly. The cron is working most of the time. And I am only using reload, not restart in my cron. It would be great to know the reason and the fix.

Thank you.
 
Top