Queue cron safeguard script

Started by d4f, February 27, 2017, 08:02:26 AM

d4f

I've had the new queue cronjob fill up my process list and shoot the load through the roof several times now because for some reason it does not always terminate correctly within a given time and also doesn't seem to have proper locking mechanisms.
To prevent it from running off, here is a small wrapper script:
#!/usr/bin/env bash
LOCKFILE="/tmp/hostbill_queue.lock"
QUEUE="/home/YOURUSER/public_html/queue.php"

#Check if lockfile exists and has valid PID
echo -n "Checking lock... "
if [ -e "$LOCKFILE" ]; then
        #Check if lockfile PID still exists
        kill `cat $LOCKFILE` > /dev/null 2>&1 && ( echo "running!"; exit 1 )
        echo "dead"
else
        echo "stopped"
fi

#Write log file
echo $$ > $LOCKFILE

#Start actual queue tool
php -q $QUEUE

#Remove queue lock if script ends
rm -f $LOCKFILE

thewebexpert

my problem is that queue.php never seems to come back .... It nearly killed my server spawing processes.... I will let it run once for 10 mins to see if it ever finishes... any ideas?


silas_i

Anyone activated this queue?

I'm activate but after a few minutes the load os server is too HIGH that I needed reboot server.


thewebexpert

the problem is that the process spawns a bunch of processes that never exit, then every minute it repeats until there is no more ram -sigh- just try running it from the shell window and you will see

4service

still having problems with the php -q /home/mydomain/public_html/manager/queue.php kills my server.
hostbill  Version: 2017-03-20:2017
PHP 7
cPanel EA4

PHP extensions: POSIX and PCNTL.  is no option with Mod Ruid2

If option above is not possible to do, duplicate cron entry for queue.php multiple times (ie 5x): not possible in cpanel

thewebexpert

php -q /home/mydomain/public_html/HOSTBILL/queue.php -r works fine on my server.

4service

Thanks thewebexpert,
queue.php -r did it.
Server runs normal load.