Repository navigation
Expand file tree
/
Copy pathwait_ticket.csh
More file actions
executable file
·106 lines (86 loc) · 2.74 KB
/
Copy pathwait_ticket.csh
File metadata and controls
executable file
·106 lines (86 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#! /bin/csh -f
#
# wait_ticket.csh ticket
# call with ticketID
set noglob
set here = $cwd
cd $WORKFLOW_DATA
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 $WORKFLOW_DATA
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 $WORKFLOW_DATA
if ($foundpath == "NOTFOUND") then
foreach queue ( tasks/$task/done tasks/$task/archive/ok tasks/$task/archive/failed )
cd $WORKFLOW_DATA/$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