#!/bin/tcsh
set URL=http://mintaka.aip.de:24005/context
set snapshot=snapshot.rdf
set workdir=${HOME}/information_service/stable
cd ${workdir}
# get snapshot of current RDF contents
wget -T 50 -t 1 -O context ${URL}
set wget_result=$?
if (-s context) then
/bin/mv context $snapshot
endif
if ($wget_result != 0) then
setenv PYTHONPATH ${workdir}/_install/lib/python2.4
setenv PATH ${workdir}/_install/bin:${PATH}
set pid=`cat twistd.pid`
echo Killing old service instance with PID $pid
/bin/kill -1 $pid
echo Starting new service instance
twistd -oy service/ServeREST.py
echo Uploading latest RDF snapshot
curl --upload-file $snapshot ${URL}
endif