Skip to content

Commit 5ba3cd7

Browse files
committed
Make update-db use simple output, rather than logging to logfile. Some tweaks to diagnostic output text.
- Legacy-Id: 641
1 parent 258ab62 commit 5ba3cd7

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

test/update-db

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ progdir=${0%/*}
99
cd $progdir/..
1010
build=$PWD
1111

12-
function log() { logger -i -t $program -s "$*"; }
13-
function die() { log "$*; terminating."; echo "$program: Error: $*" 1>&2; exit 1; }
12+
function die() { echo "$*; terminating."; echo "$program: Error: $*" 1>&2; exit 1; }
1413

1514

1615
for dir in /var/local /var/state /var/run /var/tmp; do
@@ -45,31 +44,33 @@ while true; do
4544
#echo "Database dump file is from $(date -r $DBDUMP +'%Y-%m-%d %H:%M')."
4645
#echo "Last update done $(date -r $DBDONE +'%Y-%m-%d %H:%M')."
4746
if [ $DBDUMP -nt $DBTIME ]; then
47+
echo "Updating database dated $(date -r $DBDONE +'%Y-%m-%d %H:%M') from dump with time $(date -r $DBDUMP +'%Y-%m-%d %H:%M')"
48+
4849
echo "$$" > $PIDFILE
4950
chmod a+rw $PIDFILE
5051

51-
log "Updating local database from $DBDUMP ..."
52+
echo "Updating local database from $DBDUMP ..."
5253
python ietf/manage.py dbshell < $DBDUMP
53-
log "Updating local database from $DBFIX ..."
54+
echo "Updating local database from $DBFIX ..."
5455
python ietf/manage.py dbshell < $DBFIX
55-
log "Running Django syncdb ..."
56+
echo "Running Django syncdb ..."
5657
python ietf/manage.py syncdb
5758
touch -r $DBDUMP $DBTIME
5859
touch $DBDONE
59-
log "Done."
60-
# else
61-
# echo "No new database dump available."
60+
echo "Done."
61+
else
62+
echo "Database is up-to-date (updated $(date -r $DBDONE +'%Y-%m-%d %H:%M') from dump with time $(date -r $DBDUMP +'%Y-%m-%d %H:%M'))"
6263
fi
6364
rm -rf $DBLOCK
6465
exit 0
6566
else
6667
pid=$(< $PIDFILE ) || die "Couldn't read pidfile '$PIDFILE'"
6768
if kill -0 $pid; then
68-
log "Pidfile for process $pid exists, and process is running. Sleeping."
69+
echo "Pidfile for process $pid exists, and process is running. Sleeping."
6970
sleep 10
7071
else
71-
log "Pidfile for process $pid exists, but process isn't running."
72-
log "Removing lock and old pid file $pidfile."
72+
echo "Pidfile for process $pid exists, but process isn't running."
73+
echo "Removing lock and old pid file $pidfile."
7374
rm -rf $DBLOCK
7475
fi
7576
fi

0 commit comments

Comments
 (0)