2015-08-02 06:37:44 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2016-01-11 16:04:40 +00:00
|
|
|
PYTHON="coverage run -a"
|
2015-08-02 06:37:44 +00:00
|
|
|
URL=http://127.0.0.1/file
|
|
|
|
|
|
|
|
|
|
|
|
# setup processes
|
|
|
|
$PYTHON shadowsocks/local.py -c tests/graceful.json &
|
|
|
|
LOCAL=$!
|
|
|
|
|
|
|
|
$PYTHON shadowsocks/server.py -c tests/graceful.json --forbidden-ip "" &
|
|
|
|
SERVER=$!
|
|
|
|
|
|
|
|
python tests/graceful_server.py &
|
|
|
|
GSERVER=$!
|
|
|
|
|
|
|
|
sleep 1
|
|
|
|
|
|
|
|
python tests/graceful_cli.py &
|
|
|
|
GCLI=$!
|
|
|
|
|
|
|
|
sleep 1
|
|
|
|
|
|
|
|
# graceful restart server: send SIGQUIT to old process and start a new one
|
|
|
|
kill -s SIGQUIT $SERVER
|
2015-08-02 07:12:41 +00:00
|
|
|
sleep 0.5
|
2015-08-02 06:37:44 +00:00
|
|
|
$PYTHON shadowsocks/server.py -c tests/graceful.json --forbidden-ip "" &
|
|
|
|
NEWSERVER=$!
|
|
|
|
|
|
|
|
sleep 1
|
|
|
|
|
|
|
|
# check old server
|
|
|
|
ps x | grep -v grep | grep $SERVER
|
|
|
|
OLD_SERVER_RUNNING1=$?
|
|
|
|
# old server should not quit at this moment
|
|
|
|
echo old server running: $OLD_SERVER_RUNNING1
|
|
|
|
|
|
|
|
sleep 1
|
|
|
|
|
|
|
|
# close connections on old server
|
2015-08-02 07:12:41 +00:00
|
|
|
kill -s SIGKILL $GCLI
|
2015-08-02 06:37:44 +00:00
|
|
|
kill -s SIGKILL $GSERVER
|
|
|
|
kill -s SIGINT $LOCAL
|
|
|
|
|
|
|
|
sleep 11
|
|
|
|
|
|
|
|
# check old server
|
|
|
|
ps x | grep -v grep | grep $SERVER
|
|
|
|
OLD_SERVER_RUNNING2=$?
|
|
|
|
# old server should quit at this moment
|
|
|
|
echo old server running: $OLD_SERVER_RUNNING2
|
|
|
|
|
2015-08-02 07:12:41 +00:00
|
|
|
kill -s SIGINT $SERVER
|
2015-08-02 06:37:44 +00:00
|
|
|
# new server is expected running
|
|
|
|
kill -s SIGINT $NEWSERVER || exit 1
|
|
|
|
|
|
|
|
if [ $OLD_SERVER_RUNNING1 -ne 0 ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $OLD_SERVER_RUNNING2 -ne 1 ]; then
|
|
|
|
sleep 1
|
|
|
|
exit 1
|
|
|
|
fi
|