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

Annotation of /productionkit/deamons/src/rrdeamon.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (hide annotations) (download) (as text) (vendor branch)
Thu Nov 30 14:09:20 2006 UTC (18 years ago) by mocchiut
Branch: productionkit, MAIN
CVS Tags: start, v0r00, HEAD
Changes since 1.1: +0 -0 lines
File MIME type: application/x-sh
Imported sources

1 mocchiut 1.1 #!/bin/bash
2    
3     source /gpfs/wizard/flight/production/installed/set_pam_env.sh > /dev/null 2>&1;
4    
5     if [ "$PAM_BIN" == "" ]; then exit; fi
6    
7     export PRODDIR=/gpfs/wizard/flight/production/
8    
9     export PRERR=$PRODDIR/preRawreader/
10    
11     export WRKDIR=$PRODDIR/deamons/wrkdir/
12    
13     export SCRIPT=$PRODDIR/deamons/script/
14    
15     export LOGDIR=$PRODDIR/logs/
16    
17     touch $WRKDIR/rr.rrlist
18    
19     LOG=$WRKDIR/rr.log
20    
21     BUSY=$WRKDIR/rrlist.busy
22    
23     touch $LOG
24    
25     touch $BUSY
26    
27     echo -n " DEAMON STARTED AT " >> $LOG;
28    
29     date >> $LOG;
30    
31     echo "300" > $WRKDIR/rr.step
32     #echo "1" > $WRKDIR/rr.step
33    
34     TIME=`tail -1 $WRKDIR/rr.step`;
35    
36     while [ $TIME -ne 0 ]; do
37    
38     ls $PRERR/*.pam &> $WRKDIR/rr.rawlist 2>/dev/null;
39     # ls $PRERR/02005001.pam &> $WRKDIR/rr.rawlist 2>/dev/null;
40    
41     echo -n "#############>>>> DATE: " >> $LOG;
42    
43     date >> $LOG;
44    
45     for nfile in `sort $WRKDIR/rr.rawlist`; do
46    
47     file=`basename $nfile`
48    
49     DONE=0;
50    
51     for procfile in `cat $WRKDIR/rr.rrlist`; do
52    
53     if [ $file == $procfile ]; then
54    
55     DONE=1;
56    
57     fi;
58    
59     done;
60    
61     if [ "$file" == "bad_files" ]; then
62    
63     DONE=1;
64    
65     fi;
66    
67     while [ $DONE -eq 0 ]; do
68    
69     NOW=`date +%s`
70    
71     CTIME=`date --reference=$nfile +%s`
72    
73     let DELTA=NOW-CTIME
74    
75     while [ $DELTA -lt 300 ]; do
76    
77     echo "File $file is hot! waiting 60 seconds..." >> $LOG;
78    
79     sleep 60;
80    
81     NOW=`date +%s`
82    
83     CTIME=`date --reference=$nfile +%s`
84    
85     let DELTA=NOW-CTIME
86    
87     done;
88    
89     echo -n "FILE IS COLD NOW: " >> $LOG;
90    
91     date >> $LOG;
92    
93     echo " Processing file $file!" >> $LOG;
94    
95     R=0;
96    
97     if [ -s $PRERR/$file ]; then
98    
99     echo " File $file is on disk! " >> $LOG;
100    
101     else
102    
103     COPY="";
104    
105     echo " File not found on disk or empty! " >> $LOG;
106    
107     date +%s >> $LOG;
108    
109     R=2;
110    
111     fi
112    
113     if [ $R -gt 1 ]; then
114    
115     echo -n " PROBLEMS! " >> $LOG;
116    
117     echo " File $file not processed yet, I will retry later " >> $LOG;
118    
119     else
120    
121     R=0;
122    
123     TEST=""
124    
125     while [ "$TEST" == "" ] && [ $R -lt 10 ]; do
126    
127     let R=$R+1;
128    
129     NOME=`basename $file .pam`
130    
131     QUEUE=ts_wizard
132    
133     CHECK=`bhist -q "${QUEUE}" -p`;
134    
135     while [ "$CHECK" != "No matching job found" ]; do
136    
137     sleep 20;
138    
139     CHECK=`bhist -q "${QUEUE}" -p`;
140    
141     if [ "$CHECK" != "No matching job found" ]; then
142    
143     CHECK2=`bhist -q "normal" -p`;
144    
145     if [ "$CHECK2" == "No matching job found" ]; then
146    
147     echo " Using normal queue since ts_wizard is full " >> $LOG;
148    
149     QUEUE="normal";
150    
151     CHECK=`bhist -q "${QUEUE}" -p`;
152    
153     fi;
154    
155     fi;
156    
157     done;
158    
159     SUBO=`bsub -q $QUEUE -oo $LOGDIR/rr.lsf.$NOME.log $SCRIPT/rr.sh $file`;
160    
161     echo " Output from LSF is: $SUBO " >> $LOG;
162    
163     TEST=`echo $SUBO | grep "is submitted"`;
164    
165     if [ "$TEST" == "" ]; then
166    
167     echo " Send LSF job failure! " >> $LOG;
168    
169     echo " Retry n. $R " >> $LOG;
170    
171     fi
172    
173     done
174    
175     if [ $R -ge 10 ]; then
176    
177     echo -n " PROBLEMS SENDING LSF JOBS! " >> $LOG;
178    
179     date >> $LOG;
180    
181     echo " File $file not processed yet, I will retry later " >> $LOG;
182    
183     else
184    
185     CHOK=`tail -1 $BUSY`;
186    
187     if [ "$CHOK" == "" ]; then
188    
189     echo "0" > $BUSY;
190    
191     CHOK=`tail -1 $BUSY`;
192    
193     fi
194    
195     while [ $CHOK -eq 1 ]; do
196    
197     echo -n " LIST FILE IS BUSY " >> $LOG;
198    
199     date >> $LOG;
200    
201     sleep 1;
202    
203     CHOK=`tail -1 $BUSY `;
204    
205     done
206    
207     echo "1" > $BUSY;
208    
209     echo $file >> $WRKDIR/rr.rrlist;
210    
211     echo "0" > $BUSY;
212    
213     # sleep 127;
214    
215     fi;
216    
217     fi;
218    
219     DONE=1;
220    
221     done;
222    
223     TIME=`tail -1 $WRKDIR/rr.step `;
224    
225     if [ $TIME -le 0 ]; then
226    
227     echo -n " EXIT DEAMON, RECEIVED TERM SIGNAL " >> $LOG;
228    
229     date >> $LOG;
230    
231     exit;
232    
233     fi
234    
235     while [ $TIME -eq 1 ]; do
236    
237     TIME=`tail -1 $WRKDIR/rr.step `;
238    
239     echo -n " TIME = 1! DEAMON PAUSE " >> $LOG;
240    
241     date >> $LOG;
242    
243     sleep 120;
244    
245     done
246    
247     done;
248    
249     TIME=`tail -1 $WRKDIR/rr.step `;
250    
251     if [ $TIME -le 0 ]; then
252    
253     echo -n " EXIT DEAMON, RECEIVED TERM SIGNAL " >> $LOG;
254    
255     date >> $LOG;
256    
257     exit;
258    
259     fi
260    
261     while [ $TIME -eq 1 ]; do
262    
263     TIME=`tail -1 $WRKDIR/rr.step `;
264    
265     echo -n " TIME = 1! DEAMON PAUSE " >> $LOG;
266    
267     date >> $LOG;
268    
269     sleep 120;
270    
271     done
272    
273     sleep $TIME;
274    
275     TIME=`tail -1 $WRKDIR/rr.step `;
276    
277     done;
278    
279     echo -n " EXIT DEAMON, RECEIVED TERM SIGNAL " >> $LOG;
280    
281     date >> $LOG;

  ViewVC Help
Powered by ViewVC 1.1.23