forked from bgruening/docker-ipython-notebook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmonitor_traffic.sh
23 lines (19 loc) · 901 Bytes
/
monitor_traffic.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash
# Take the netstat output the estimate if the client is still connected to
# the IPython Notebook server. The 'CLOSE_WAIT' state will be ignored. It
# Indicates that the server has received the first FIN signal from the client
# and the connection is in the process of being closed. But that can never happen.
# For some reason there are a few connections open that do not relate the the
# client that needs to be connected over the port :6789. If we do not have a
# connection open from port 6789, kill the server and herewith the docker container.
if [ `netstat -t | grep -v CLOSE_WAIT | grep ':6789' | wc -l` -lt 3 ]
then
if [ -e "/tmp/monitor_run" ];
then
pkill ipython
# We will create new history elements with all data that is relevant,
# this means we can delete everything from /import/
rm /import/ -rf
fi
fi
touch /tmp/monitor_run