Changeset 533


Ignore:
Timestamp:
Jun 26, 2010, 2:43:38 PM (10 years ago)
Author:
zecrazytux
Message:

Use wait' & trap', see #18

File:
1 edited

Legend:

Unmodified
Added
Removed
  • jobq/jobq

    r528 r533  
    6363
    6464queue_runner() {
     65  trap ":" USR1
    6566  echo "queue runner started for user/queue '$LOGNAME/$queue' (pid $$)" | logger -t $PROGRAM
    6667
     
    99100    else
    100101      # No job, re-scan the queue later
    101       sleep 5
     102      sleep 25 & wait $!
     103      kill $!
    102104    fi
    103105  done
     
    105107
    106108queue_runner_daemon() {
     109  set +e
    107110  # Make sure the queue path exists so we can write our pidfile
    108111  mkdir -m 0700 -p $JOBPATH/$queue
     
    118121  if [ $? = 1 ]; then
    119122    # Daemon is already running, wake it up to process new job immediatly
    120     sleeppid=$(ps -o pid,cmd --ppid $(cat "$pidfile") --noheadings | awk '/sleep/{ print $1 }')
    121     if [ -z "$sleeppid" ]; then
    122       kill -USR1 "$sleeppid"
    123     fi
     123    kill -USR1 $(cat "$pidfile")
    124124  fi
    125125  if [ $? != 0 ]; then
Note: See TracChangeset for help on using the changeset viewer.