From 863a1dbca0fa317a76eaac4a23da5b3249938c78 Mon Sep 17 00:00:00 2001 From: "Wang,Jeff" Date: Mon, 5 Feb 2018 11:17:06 -0800 Subject: [PATCH 1/3] Fix python path typo in the start dev server script Kill webpack in case of python error. --- scripts/setup_dev_env.sh | 2 +- scripts/start_dev_server.sh | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/scripts/setup_dev_env.sh b/scripts/setup_dev_env.sh index 3e2e2cfd3..4d59bf4c1 100755 --- a/scripts/setup_dev_env.sh +++ b/scripts/setup_dev_env.sh @@ -21,4 +21,4 @@ cd build cmake .. make -j $processors -export PYTHON_PATH=$PYTHON_PATH:"$SCRIPT_DIR/.." +export PYTHONPATH=$PYTHONPATH:"$SCRIPT_DIR/.." diff --git a/scripts/start_dev_server.sh b/scripts/start_dev_server.sh index 1a5dcb119..28388d974 100755 --- a/scripts/start_dev_server.sh +++ b/scripts/start_dev_server.sh @@ -6,9 +6,20 @@ CURRENT_DIR=`pwd` SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $SCRIPT_DIR/../frontend + ./node_modules/.bin/webpack --watch --config tool/webpack.dev.config.js --output-path=../visualdl/server/dist & +# Track webpack pid +WEBPACKPID=$! -export PYTHON_PATH=$PYTHON_PATH:"$SCRIPT_DIR/.." +export PYTHONPATH=$PYTHONPATH:"$SCRIPT_DIR/.." cd $CURRENT_DIR -python ${SCRIPT_DIR}/../visualdl/server/visualDL "$@" + +{ + # Run the visualDL with local PATH + python ${SCRIPT_DIR}/../visualdl/server/visualDL "$@" +} || +{ + # Catch python error, clean up the webpack process. + kill -9 $WEBPACKPID +} From 1ee852aefe519513a0f62d576edbf1a1aee698c1 Mon Sep 17 00:00:00 2001 From: "Wang,Jeff" Date: Mon, 5 Feb 2018 11:52:18 -0800 Subject: [PATCH 2/3] Switch to use trap --- scripts/start_dev_server.sh | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/scripts/start_dev_server.sh b/scripts/start_dev_server.sh index 28388d974..85d1ed8d8 100755 --- a/scripts/start_dev_server.sh +++ b/scripts/start_dev_server.sh @@ -6,20 +6,18 @@ CURRENT_DIR=`pwd` SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $SCRIPT_DIR/../frontend +export PYTHONPATH=$PYTHONPATH:"$SCRIPT_DIR/.." ./node_modules/.bin/webpack --watch --config tool/webpack.dev.config.js --output-path=../visualdl/server/dist & # Track webpack pid WEBPACKPID=$! -export PYTHONPATH=$PYTHONPATH:"$SCRIPT_DIR/.." +function finish { + kill -9 $WEBPACKPID +} +trap finish EXIT cd $CURRENT_DIR -{ - # Run the visualDL with local PATH - python ${SCRIPT_DIR}/../visualdl/server/visualDL "$@" -} || -{ - # Catch python error, clean up the webpack process. - kill -9 $WEBPACKPID -} +#Run the visualDL with local PATH +python ${SCRIPT_DIR}/../visualdl/server/visualDL "$@" From c63c6c9420b606cb76b41b039df4fb8a9b0581aa Mon Sep 17 00:00:00 2001 From: "Wang,Jeff" Date: Mon, 5 Feb 2018 12:36:29 -0800 Subject: [PATCH 3/3] capture more signal. --- scripts/start_dev_server.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/start_dev_server.sh b/scripts/start_dev_server.sh index 85d1ed8d8..a0951cc47 100755 --- a/scripts/start_dev_server.sh +++ b/scripts/start_dev_server.sh @@ -16,7 +16,8 @@ function finish { kill -9 $WEBPACKPID } -trap finish EXIT +trap finish EXIT HUP INT QUIT PIPE TERM + cd $CURRENT_DIR #Run the visualDL with local PATH