~ubuntu-branches/ubuntu/utopic/gridengine/utopic

« back to all changes in this revision

Viewing changes to source/dist/ckpt/sx6_restart_command

  • Committer: Bazaar Package Importer
  • Author(s): Mark Hymers
  • Date: 2008-06-25 22:36:13 UTC
  • Revision ID: james.westby@ubuntu.com-20080625223613-tvd9xlhuoct9kyhm
Tags: upstream-6.2~beta2
ImportĀ upstreamĀ versionĀ 6.2~beta2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
#
 
3
#
 
4
#___INFO__MARK_BEGIN__
 
5
##########################################################################
 
6
#
 
7
#  The Contents of this file are made available subject to the terms of
 
8
#  the Sun Industry Standards Source License Version 1.2
 
9
#
 
10
#  Sun Microsystems Inc., March, 2001
 
11
#
 
12
#
 
13
#  Sun Industry Standards Source License Version 1.2
 
14
#  =================================================
 
15
#  The contents of this file are subject to the Sun Industry Standards
 
16
#  Source License Version 1.2 (the "License"); You may not use this file
 
17
#  except in compliance with the License. You may obtain a copy of the
 
18
#  License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
 
19
#
 
20
#  Software provided under this License is provided on an "AS IS" basis,
 
21
#  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 
22
#  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 
23
#  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 
24
#  See the License for the specific provisions governing your rights and
 
25
#  obligations concerning the Software.
 
26
#
 
27
#  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 
28
#
 
29
#  Copyright: 2001 by Sun Microsystems, Inc.
 
30
#
 
31
#  All Rights Reserved.
 
32
#
 
33
##########################################################################
 
34
#___INFO__MARK_END__
 
35
 
 
36
set +u    # don't treat unset parameters as an error
 
37
set +e    # don't exit on bad command status
 
38
 
 
39
ckpt_dir=$3
 
40
 
 
41
if [ ! -f $ckpt_dir/ckpt.log ]; then
 
42
   touch $ckpt_dir/ckpt.log
 
43
   chmod 666 $ckpt_dir/ckpt.log
 
44
fi
 
45
 
 
46
if [ "$SGE_TASK_ID" = "undefined" -o "$SGE_TASK_ID" = "" ]; then
 
47
   jobid=$JOB_ID
 
48
   jobdir=$JOB_ID.1
 
49
else
 
50
   jobid=$JOB_ID.$SGE_TASK_ID
 
51
   jobdir=$JOB_ID.$SGE_TASK_ID
 
52
fi
 
53
 
 
54
#
 
55
# create temp directory for holding checkpoint info
 
56
#
 
57
 
 
58
tmpdir=$ckpt_dir/ckpt.$jobid
 
59
mkdir -p $tmpdir
 
60
cd $tmpdir
 
61
 
 
62
#
 
63
# create log file
 
64
#
 
65
 
 
66
F=$tmpdir/checkpoint.log
 
67
touch $F
 
68
exec >> $F 2>&1
 
69
 
 
70
echo -------------------------------------------------------------
 
71
echo `basename $0` called at `date`
 
72
echo called by: `id`
 
73
echo with args: $*
 
74
 
 
75
#
 
76
# Get original job_pid and osjobid
 
77
#
 
78
 
 
79
job_pid=`cat job_pid`
 
80
osjobid=`cat osjobid`
 
81
 
 
82
# restore the O.S. job identifier to the jobs directory
 
83
# NOTE: do we need to restore osjobid?
 
84
# NOTE: do we need to restore job_pid?
 
85
job_dir=`dirname $JOB_SCRIPT`/../active_jobs/$jobdir
 
86
echo original job_pid=$job_pid
 
87
echo original osjobid=$osjobid
 
88
ls -la $job_dir/job_pid
 
89
cat $job_dir/job_pid
 
90
ls -la $job_dir/osjobid
 
91
cat $job_dir/osjobid
 
92
#echo $job_pid > $job_dir/job_pid
 
93
#echo $osjobid > $job_dir/osjobid
 
94
 
 
95
echo `date +"%D %T"` Job $jobid "(job_pid=$job_pid, osjobid=$osjobid)" restarting >> $ckpt_dir/ckpt.log
 
96
 
 
97
#
 
98
# If previous restart file exists, we assume that we
 
99
# died during a checkpoint and we should recover using
 
100
# this file
 
101
#
 
102
 
 
103
if [ -f chkpnt_$jobid.save ]; then
 
104
   mv chkpnt_$jobid.save chkpnt_$jobid
 
105
fi
 
106
 
 
107
#
 
108
# Register restart file, just in case it's not registered. This could
 
109
# happen if the host died during the last checkpoint
 
110
#
 
111
 
 
112
echo /usr/bin/rsvresf chkpnt_$jobid
 
113
/usr/bin/rsvresf chkpnt_$jobid
 
114
 
 
115
#
 
116
# Now restart the job and wait for it to complete
 
117
#
 
118
 
 
119
echo /usr/bin/restart -f -i -w chkpnt_$jobid
 
120
/usr/bin/restart -f -i -w chkpnt_$jobid
 
121
exit_status=$?
 
122
echo Exit status of restart command: $exit_status
 
123
 
 
124
# Now be careful: The restart command is the parent process of the restarted
 
125
# job. Grid Engine is the parent process of the restart command.
 
126
# If the job was killed (probably due to a migration request), we need to
 
127
# tell our parent that by killing ourselves. Grid Engine will also detect an 
 
128
# exit status > 128 analogous to a KILL
 
129
 
 
130
#if [ $exit_status = 1 ]
 
131
#then
 
132
#   jstat=`/bin/acctcom -j $job_id -b -p -Z -f -v /usr/adm/acct/day/pacct | $SGE_ROOT/ckpt/cray_parse_job_status $2`
 
133
#   echo "jobstatus $job_id $2 = $jstat"
 
134
#   if [ "$jstat" = "" ]
 
135
#   then
 
136
#      exit_status=100
 
137
#   elif [ "$jstat" = "0" ]
 
138
#   then
 
139
#      exit_status=0
 
140
#   else
 
141
#      exit_status=`expr $jstat + 128`
 
142
#   fi
 
143
#fi
 
144
 
 
145
# If killing ourselves didn't help or the exit_status was  < 128 exit 
 
146
# with the exit status of our child
 
147
 
 
148
echo `date +"%D %T"` Job $jobid "(job_pid=$job_pid, osjobid=$osjobid) exiting, status=$exit_status" >> $ckpt_dir/ckpt.log
 
149
 
 
150
echo Exiting with exit status: $exit_status
 
151
exit $exit_status
 
152