/[PAMELA software]/productionkit/deamons/src/dvdeamon.sh
ViewVC logotype

Contents of /productionkit/deamons/src/dvdeamon.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download) (as text)
Thu Nov 30 14:09:20 2006 UTC (18 years, 1 month ago) by mocchiut
Branch point for: productionkit, MAIN
File MIME type: application/x-sh
Initial revision

1 #!/bin/bash
2
3 #
4 # !!! AGGIUNGERE RETRIEVING TLE!
5 #
6
7 source /gpfs/wizard/flight/production/installed/set_pam_env.sh > /dev/null 2>&1;
8
9 if [ "$PAM_BIN" == "" ]; then exit; fi
10
11 export PRODDIR=/gpfs/wizard/flight/production/
12
13 export POSTRR=$PRODDIR/postRawreader/
14
15 export L0=$PRODDIR/level0/
16
17 export WRKDIR=$PRODDIR/deamons/wrkdir/
18
19 export LOGDIR=$PRODDIR/logs/
20
21 export SCRIPT=$PRODDIR/deamons/script/
22
23 export DB=pamela
24 #export DB=test
25
26 export HOST=srv-g2-01.ts.infn.it
27
28 export USER=root
29
30 export PSW=Calo0%Ts
31
32 touch $WRKDIR/dv.dvlist
33
34 LOG=$WRKDIR/dv.log
35
36 BUSY=$WRKDIR/dvlist.busy
37
38 touch $LOG
39
40 touch $BUSY
41
42 echo -n " DEAMON STARTED AT " >> $LOG;
43
44 date >> $LOG;
45
46 echo "494" > $WRKDIR/dv.step
47
48 TIME=`tail -1 $WRKDIR/dv.step`;
49
50 while [ $TIME -gt 0 ]; do
51
52 echo " Retrieving latest TLE " >> $LOG;
53
54 $SCRIPT/retrieve_TLE.sh --output=$WRKDIR/tle.txt >> $LOG 2>&1;
55
56 if [ -s $WRKDIR/tle.txt ]; then
57
58 echo " Calling YodaProfiler to fill TLE in the DB " >> $LOG;
59
60 YodaProfiler -tle $WRKDIR/tle.txt >> $LOG 2>&1;
61
62 fi
63
64 PRIMA=`date -u +%s`
65
66 let PRIMA=$PRIMA-7200
67
68 export QUERY="select ID from GL_RUN where INSERT_TIME<FROM_UNIXTIME('${PRIMA}')"
69
70 mysql --host=$HOST -u $USER --password=$PSW --execute="${QUERY}" $DB | sed 's/|//g' | tr -d [ID] &> $WRKDIR/dv.runlist ;
71
72 # mysql --host=$HOST -u $USER --password=$PSW --execute="select ID from GL_RUN where VALIDATION=1;" $DB | sed 's/|//g' | tr -d [ID] &> $WRKDIR/dv.runlist ;
73 # echo "6622" > $WRKDIR/dv.runlist;
74
75 for run in `sort $WRKDIR/dv.runlist`; do
76
77 DONE=0;
78
79 for rundone in `cat $WRKDIR/dv.dvlist`; do
80
81 if [ $run -eq $rundone ]; then
82
83 DONE=1;
84
85 fi;
86
87 done;
88
89 if [ $DONE -eq 0 ]; then
90
91 echo " Submitting job for run $run "
92
93 sleep 1;
94
95 R=0;
96
97 TEST=""
98
99 while [ "$TEST" == "" ] && [ $R -lt 10 ]; do
100
101 let R=$R+1;
102
103 QUEUE=ts_wizard
104
105 CHECK=`bhist -q "${QUEUE}" -p`;
106
107 while [ "$CHECK" != "No matching job found" ]; do
108
109 sleep 20;
110
111 CHECK=`bhist -q "${QUEUE}" -p`;
112
113 if [ "$CHECK" != "No matching job found" ]; then
114
115 CHECK2=`bhist -q "normal" -p`;
116
117 if [ "$CHECK2" == "No matching job found" ]; then
118
119 echo " Using normal queue since ts_wizard is full " >> $LOG;
120
121 QUEUE="normal";
122
123 CHECK=`bhist -q "${QUEUE}" -p`;
124
125 fi;
126
127 fi;
128
129 done;
130
131 SUBO=`bsub -q $QUEUE -oo $LOGDIR/dv.lsf.$run.log $SCRIPT/dv.sh $run`;
132
133 echo " Output from LSF is: $SUBO " >> $LOG;
134
135 TEST=`echo $SUBO | grep "is submitted"`;
136
137 if [ "$TEST" == "" ]; then
138
139 echo " Send LSF job failure! " >> $LOG;
140
141 echo " Retry n. $R " >> $LOG;
142
143 fi
144
145 done
146
147 if [ $R -ge 10 ]; then
148
149 echo -n " PROBLEMS SENDING LSF JOBS! " >> $LOG;
150
151 date >> $LOG;
152
153 echo " Run $run not processed yet, I will retry later " >> $LOG;
154
155 else
156
157 CHOK=`tail -1 $BUSY`;
158
159 if [ "$CHOK" == "" ]; then
160
161 echo "0" > $BUSY;
162
163 CHOK=`tail -1 $BUSY`;
164
165 fi
166
167 while [ $CHOK -eq 1 ]; do
168
169 echo -n " LIST FILE IS BUSY " >> $LOG;
170
171 date >> $LOG;
172
173 sleep 1;
174
175 CHOK=`tail -1 $BUSY `;
176
177 done
178
179 echo "1" > $BUSY;
180
181 echo $run >> $WRKDIR/dv.dvlist;
182
183 echo "0" > $BUSY;
184
185 TIME=`tail -1 $WRKDIR/dv.step `;
186
187 while [ $TIME -eq 1 ]; do
188
189 echo -n " TIME = 1! DEAMON PAUSE " >> $LOG;
190
191 date >> $LOG;
192
193 sleep 120;
194
195 TIME=`tail -1 $WRKDIR/dv.step `;
196
197 done
198
199 if [ $TIME -le 0 ]; then
200
201 echo -n " EXIT DEAMON, RECEIVED TERM SIGNAL " >> $LOG;
202
203 date >> $LOG;
204
205 exit;
206
207 fi;
208
209 fi;
210
211 fi;
212
213 done;
214
215 TIME=`tail -1 $WRKDIR/dv.step `;
216
217 while [ $TIME -eq 1 ]; do
218
219 echo -n " TIME = 1! DEAMON PAUSE " >> $LOG;
220
221 date >> $LOG;
222
223 sleep 120;
224
225 TIME=`tail -1 $WRKDIR/dv.step `;
226
227 done;
228
229 if [ $TIME -le 0 ]; then
230
231 echo -n " EXIT DEAMON, RECEIVED TERM SIGNAL " >> $LOG;
232
233 date >> $LOG;
234
235 exit;
236
237 fi
238
239 sleep $TIME;
240
241 TIME=`tail -1 $WRKDIR/dv.step `;
242
243 done;
244
245 echo -n " EXIT DEAMON, RECEIVED TERM SIGNAL " >> $LOG;
246
247 date >> $LOG;

  ViewVC Help
Powered by ViewVC 1.1.23