(file) Return to wait_ticket.csh CVS log (file) (dir) Up to [Development] / JSOC / proj / workflow

File: [Development] / JSOC / proj / workflow / wait_ticket.csh (download) / (as text)
Revision: 1.3, Thu Feb 24 04:31:13 2011 UTC (11 years, 9 months ago) by phil
Branch: MAIN
CVS Tags: Ver_LATEST, Ver_9-5, Ver_9-41, Ver_9-4, Ver_9-3, Ver_9-2, Ver_9-1, Ver_9-0, Ver_8-8, Ver_8-7, Ver_8-6, Ver_8-5, Ver_8-4, Ver_8-3, Ver_8-2, Ver_8-12, Ver_8-11, Ver_8-10, Ver_8-1, Ver_8-0, Ver_7-1, Ver_7-0, Ver_6-4, Ver_6-3, Ver_6-2, Ver_6-1, Ver_6-0, Ver_5-14, Ver_5-13, HEAD
Changes since 1.2: +9 -5 lines
misc, and new gatekeeper.restart

#! /bin/csh -f
#
# wait_ticket.csh ticket
# call with ticketID

set noglob

set here = $cwd

if ($?WORKFLOW_ROOT) then
  set WFDIR = $WORKFLOW_DATA
  set WFCODE = $WORKFLOW_ROOT
else
  echo Need WORKFLOW_ROOT variable to be set.
  exit 1
endif

cd $WFDIR

set ticket = $1
if ($#ticket < 1 || $ticket[1] == '***') then
   echo "Invalid ticket $ticket"
   exit 1
endif

set gate = `echo $ticket | sed -e 's/-.*//'`

if (!( -e gates/$gate)) then
   echo "No gate matching the ticket found"
   exit 1
endif

set task = `cat gates/$gate/actiontask`
if (!( -e tasks/$task)) then
   echo "No task found for the ticket's gate"
   exit 1
endif

# Look in the terminal places for the ticket.
# at present, -root task instancew will end up in the "done" directory.
# later, when a -root ticket manager is made, they should be moved to
# the archive ok or failed pools.

# list of task instances in the done pool may be quite large,
# may need to find tasks with dates equal or maybe a day later
# then the ticket itself to manage the search.

# for now, just look at all of them

set WASFOUND = 0

while (1)

  cd $WFDIR
  set foundpath = "NOTFOUND"
  # first look in new_tickets
  if (-e gates/$gate/new_tickets/$ticket) then
    set foundpath = "PENDING"
    set WASFOUND = 1
    goto KEEPWAITING
  endif
  # next in gate's active_tickets
  if (-e gates/$gate/active_tickets/$ticket) then
    set foundpath = "PENDING"
    set WASFOUND = 1
    goto KEEPWAITING
  endif

  cd $WFDIR
  if ($foundpath == "NOTFOUND") then
    foreach queue ( tasks/$task/done tasks/$task/archive/ok tasks/$task/archive/failed )
      cd $WFDIR/$queue
      foreach taskid (`/bin/ls`)
        if ($taskid =~ "*-root") continue
        set thisticket = `grep TICKET  $taskid/ticket`
        if ($#thisticket) then
          set $thisticket  # not there is a variable TICKET containing the ticketid that casued this taskinstance
          if ($ticket == $TICKET) then
            set foundpath = $cwd/$taskid
            break
          endif
        else
          echo task instance at $cwd/$taskid has no ticket
        endif
      end
      if ($foundpath != "NOTFOUND") break
    end
  endif
  
  if ($foundpath != "NOTFOUND") then # Found the task instance for this ticket
    set ticket_status = `grep STATUS $foundpath/ticket`
    set STATUS = 999
    if ($#ticket_status) set $ticket_status 
  
    cat $foundpath/ticket
    echo TASKPATH=$foundpath
    if ($STATUS >= 5) exit 1
    exit 0
  endif

KEEPWAITING:
  if ($foundpath == "NOTFOUND") then
    if ($WASFOUND) then
      echo $ticket processing complete
    else
      echo $ticket not active
    endif
    exit 0
  endif

sleep 10
end

Karen Tian
Powered by
ViewCVS 0.9.4