Allowing Ctrl-C to stop the locally run server.
Change-Id: I8767cdf8af6157a291ae1588cd7dc46eb4cc4c34
diff --git a/tools/package/onos-run-karaf b/tools/package/onos-run-karaf
index d7a7bd4..f27428e 100755
--- a/tools/package/onos-run-karaf
+++ b/tools/package/onos-run-karaf
@@ -78,12 +78,18 @@
./bin/onos-service server "$@" &>onos.log &
echo "$!" > /tmp/onos.pid
+function killServer() {
+ echo "Killing ONOS server..."
+ kill -9 $(cat /tmp/onos.pid) 2>/dev/null
+}
+
# Hang-on a bit and then start tailing the ONOS log output
MAX_RETRY=30
echo "Waiting for karaf.log"
until [ $MAX_RETRY -le 0 ]; do
KARAF_LOG=$(find $ONOS_HOME -type f -name karaf.log)
if [ $KARAF_LOG ]; then
+ trap killServer INT
tail -f $KARAF_LOG
return
fi
@@ -91,4 +97,4 @@
sleep 1
done
echo "Fail to open karaf.log"
-
+killServer