Unable to restart HTTP service

Post your questions about Web Server usage and Apache + PHP + MySQL/SQLite web applications.
Post Reply
anupam.panta
New here
Posts: 2
Joined: Tue Sep 27, 2022 1:43 pm

Unable to restart HTTP service

Post by anupam.panta »

I having issue while trying to restart HTTP service. Following up the docs, I tried using following commands,

Code: Select all

#/etc/init.d/Qthttpd.sh start
#/etc/init.d/thttpd.sh start
This cause following errors:

Code: Select all

[~] # /etc/init.d/Qthttpd.sh start
/etc/init.d/Qthttpd.sh: line 178: 25835398 - : syntax error: operand expected (error token is " ")
[~] # /etc/init.d/thttpd.sh start
/etc/init.d/thttpd.sh: line 179: 25835404 - : syntax error: operand expected (error token is " ")

Details of my QNAP:
QTS
TS-879U-RP
Version: 4.3.6.0993 (2019/07/04)
Thanks in advance.
FSC830
Experience counts
Posts: 2043
Joined: Thu Mar 03, 2016 1:11 am

Re: Unable to restart HTTP service

Post by FSC830 »

Why did you try to restart https?
This service is usually started on reboot and there is no need for restarting when NAS is running.
The shell script is originally from QNAP. Did you check, what is written in line 178/179?

Regards
anupam.panta
New here
Posts: 2
Joined: Tue Sep 27, 2022 1:43 pm

Re: Unable to restart HTTP service

Post by anupam.panta »

Hi,
My QNAP is going laggy in UI. I am unable to manage users and file permission and the file station is also not running. While Storage and Snapshot and few other services are running fine ... That's why, I want to restart only HTTP server, server reboot is not an option in my case.

My apologies, I meant to write restart/reload only HTTP only, not start.

Code: Select all

[~] # /etc/init.d/Qthttpd.sh restart
/etc/init.d/Qthttpd.sh: line 178: 25847167 - : syntax error: operand expected (error token is " ")
[~] # /etc/init.d/Qthttpd.sh reload
/etc/init.d/Qthttpd.sh: line 178: 25847176 - : syntax error: operand expected (error token is " ")
[~] #
[~] # /etc/init.d/thttpd.sh restart
/etc/init.d/thttpd.sh: line 179: 25847560 - : syntax error: operand expected (error token is " ")
[~] # /etc/init.d/thttpd.sh reload
/etc/init.d/thttpd.sh: line 179: 25847565 - : syntax error: operand expected (error token is " ")


For your reference, I have attached the code block from the bash file. I have not done any changes in bash file.

Code: Select all

[~] # vi /etc/init.d/Qthttpd.sh
 162 lock_action()
 163 {
 164         local _count=0
 165         local __lock_uptime=0
 166         trap 'rm -rf "${LOCK_FILE}"' 0
 167
 168         declare -ir _timeout=$LOCK_FILE_TIMEOUT
 169
 170         if [ -f ${LOCK_FILE} ]; then
 171                 _lock_uptime=$(cat ${LOCK_FILE})
 172         fi
 173
 174         _uptime=$(cat /proc/uptime | cut -d ' ' -f 1 | cut -d '.' -f 1)
 175         while ! (set -o noclobber; echo "$_uptime"> ${LOCK_FILE}) &>/dev/null
 176         do
 177                 _lock_uptime=$(cat ${LOCK_FILE})
 178                 if [ $(( ${_uptime} - ${_lock_uptime})) -gt ${_timeout} ]; then
 179                         rm -rf ${LOCK_FILE}
 180                         continue
 181                 fi
 182                 if [ $_count -gt $LOCK_FILE_MAX_TIMEOUT  ]; then
 183                         exit 1
 184                 fi
 185                 sleep 1
 186                 _count=$(($_count+1))
 187                 _uptime=$(cat /proc/uptime | cut -d ' ' -f 1 | cut -d '.' -f 1)
 188         done
 189         return 0
 190 }

Code: Select all

[~] # vi /etc/init.d/thttpd.sh
lock_action()
{
        local _count=0
        local __lock_uptime=0
        trap 'rm -rf "${LOCK_FILE}"' 0

        declare -ir _timeout=$LOCK_FILE_TIMEOUT

        if [ -f ${LOCK_FILE} ]; then
                _lock_uptime=$(cat ${LOCK_FILE})
        fi

        _uptime=$(cat /proc/uptime | cut -d ' ' -f 1 | cut -d '.' -f 1)
        while ! (set -o noclobber; echo "$_uptime"> ${LOCK_FILE}) &>/dev/null
        do
                _lock_uptime=$(cat ${LOCK_FILE})
                if [ $(( ${_uptime} - ${_lock_uptime})) -gt ${_timeout} ]; then
                        rm -rf ${LOCK_FILE}
                        continue
                fi
                if [ $_count -gt $LOCK_FILE_MAX_TIMEOUT  ]; then
                        exit 1
                fi
                sleep 1
                _count=$(($_count+1))
                _uptime=$(cat /proc/uptime | cut -d ' ' -f 1 | cut -d '.' -f 1)
        done
        return 0
}
FSC830
Experience counts
Posts: 2043
Joined: Thu Mar 03, 2016 1:11 am

Re: Unable to restart HTTP service

Post by FSC830 »

Reboot is sometimes the best chance to cleanup some weird things.
I did not lookup all the script, but it seems that an expected file is missing when running this script.
These is not an indicator for an error, my guess is, that this file is only created in special circumstances.

At my NAS this file also does not exist when doing regular operation:

Code: Select all

[/etc/init.d] # grep -i /var/lock/ Qthttpd.sh
LOCK_FILE="/var/lock/.apache.sh.lck"

In script code:

 177                 _lock_uptime=$(cat ${LOCK_FILE})
 178                 if [ $(( ${_uptime} - ${_lock_uptime})) -gt ${_timeout} ]; then
 179                         rm -rf ${LOCK_FILE}
 180                         continue

[/etc/init.d] # ls -al /var/lock/.ap*
-rw-r--r-- 1 admin administrators 5 2022-09-27 07:19 /var/lock/.apache_proxy.port
So it seems, that a missing /var/lock/.apache.sh.lck causes the error.
Finally it confirms to me, that you should not run this script during NAS operation.

If I remember correct, I did use a

Code: Select all

/etc/init.d/services restart
to restart services, but this will affect access too!
You can check in services.sh which services are affected. But IMHO a restart is a better way to do that.

Regards
Post Reply

Return to “Web Server & Applications (Apache + PHP + MySQL / SQLite)”