Skip to content

Commit

Permalink
Daemonize: only sleep when no new jobs are found
Browse files Browse the repository at this point in the history
  • Loading branch information
steverobbins committed Sep 10, 2015
1 parent a8cade6 commit eb9ff98
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions scheduler_cron.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,15 @@ if [ "${MODE}" = "daemonize" ]; then
NEXT_WITHOUT_ID=`echo $NEXT_JOB | sed -r 's/--id [0-9]+//g'`
# Only run this schedule now if a worker is not running a job with the same code
if ! ps auxwww | grep "${SCHEDULER} --action daemonRun ${NEXT_WITHOUT_ID}" | grep -v grep 1>/dev/null 2>/dev/null ; then
"${PHP_BIN}" "${SCHEDULER}" --action daemonRun ${NEXT_JOB} &
"${PHP_BIN}" "${SCHEDULER}" --action runScheduleByIdAction ${NEXT_JOB} &
else
# Otherwise mark it as missed
"${PHP_BIN}" "${SCHEDULER}" --action daemonMultiple ${NEXT_JOB} &
fi
fi
else
sleep "${WAIT}"
fi
sleep "${WAIT}"
done
fi

Expand Down
4 changes: 2 additions & 2 deletions shell/scheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -401,11 +401,11 @@ public function daemonNextAction()
}

/**
* Run this job through the daemon
* Run a job specified by the ID
*
* @return void
*/
public function daemonRunAction()
public function runScheduleByIdAction()
{
$id = $this->getArg('id');
if (!$id) {
Expand Down

0 comments on commit eb9ff98

Please sign in to comment.