~saiarcot895/chromium-browser/chromium-browser.vivid.dev

« back to all changes in this revision

Viewing changes to debian/keep-alive.sh

  • Committer: Saikrishna Arcot
  • Date: 2013-03-08 22:57:16 UTC
  • Revision ID: saiarcot895@gmail.com-20130308225716-1c60fatbyjqc4d2j
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
# Simple keep-alive script echoing the date on stdout
 
4
# This is needed to prevent the builders from killing a build
 
5
# staying too long without producing outputs, like while
 
6
# linking chromium with ld-bfd.
 
7
#
 
8
# Usage:
 
9
#    keep-alive.sh start &
 
10
#    some actions...
 
11
#    keep-alive.sh stop
 
12
#
 
13
# Authors:
 
14
#  Fabien Tassin <fta@sofaraway.org>
 
15
# License: GPLv2 or later
 
16
 
 
17
ACTION=$1
 
18
LOCK=/var/tmp/k-a.lock
 
19
INTERVAL=5
 
20
LINTERVAL=300
 
21
 
 
22
case $ACTION in
 
23
 start)
 
24
   echo $$ > $LOCK
 
25
   T0=$(date +%s)
 
26
   T1=0
 
27
   while [ 1 ] ; do
 
28
     if [ ! -f $LOCK ] ; then
 
29
       break
 
30
     fi
 
31
     T2=$(date +%s)
 
32
     if [ $((T2-T1)) -ge $LINTERVAL ] ; then
 
33
       DELTA=$((T2-T0))
 
34
       FREE=$(free -mo | cut -c1-6,30-40 | tail -2 | awk '{ print "Free " $1 " " $2 "M" } ' | tr '\n' ' ')
 
35
       echo "[keep-alive] $(date) ($((DELTA/60)) min) [ $FREE]"
 
36
       T1=$T2
 
37
     fi
 
38
     sleep $INTERVAL
 
39
   done
 
40
   exit 0
 
41
   ;;
 
42
 stop)
 
43
   PID=$(cat $LOCK)
 
44
   rm -f $LOCK
 
45
   exit 0
 
46
   ;;
 
47
 *)
 
48
   echo "Usage: $(basename $0) [start|stop]"
 
49
   exit 1
 
50
esac