From 2b1e2a7d560e4219510f553dbd4b21b20114f101 Mon Sep 17 00:00:00 2001 From: counter2015 Date: Thu, 21 Nov 2019 18:47:15 +0800 Subject: [PATCH] [update] change relative directory to absolute directory. --- bin/deploy.sh | 9 +++++---- bin/run.sh | 11 ++++++----- bin/stop.sh | 5 +++-- bin/venv_init.sh | 8 ++++---- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/bin/deploy.sh b/bin/deploy.sh index adba484..9903f27 100755 --- a/bin/deploy.sh +++ b/bin/deploy.sh @@ -18,7 +18,8 @@ RDIR="$( dirname "$SOURCE" )" DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )" # prepare data dir -dir_names=(${DIR}"/../var/celery") +projDir=`git rev-parse --show-toplevel` +dir_names=($projDir"var/celery") for dir_name in ${dir_names[@]} do if [ ! -d ${dir_name} ]; then @@ -28,13 +29,13 @@ do done # migrate database schema -env="../env/bin/activate" +env="$projDir/env/bin/activate" if [ -f ${env} ]; then echo "use venv : $env" - source ../env/bin/activate + source $projDir/env/bin/activate else echo "venv not found, use local environment" fi -python "../manage.py" migrate +python "$projDir/manage.py" migrate diff --git a/bin/run.sh b/bin/run.sh index abe7e16..8f01f8f 100755 --- a/bin/run.sh +++ b/bin/run.sh @@ -1,19 +1,20 @@ #!/usr/bin/env bash +projDir=`git rev-parse --show-toplevel` -env="../env/bin/activate" +env="$projDir/env/bin/activate" if [ -f ${env} ]; then echo "use venv : $env" - source ../env/bin/activate + source $projDir/env/bin/activate else echo "venv not found, use local environment" fi -nohup python3 "../manage.py" runserver 0:8011 >> ../var/server.log_`date "+%Y-%m-%d"` 2>&1 & +nohup python3 "$projDir/manage.py" runserver 0:8011 >> $projDir/var/server.log_`date "+%Y-%m-%d"` 2>&1 & pid=$! echo pid=$pid -echo $pid > ../var/pid +echo $pid > $projDir/var/pid + -projDir=`git rev-parse --show-toplevel` cd $projDir diff --git a/bin/stop.sh b/bin/stop.sh index 57aae78..c63cfcb 100755 --- a/bin/stop.sh +++ b/bin/stop.sh @@ -1,10 +1,11 @@ #!/usr/bin/env bash +projDir=`git rev-parse --show-toplevel` -pid=`cat ../var/pid` +pid=`cat $projDir/var/pid` kill $pid echo stop pid=$pid -projDir=`git rev-parse --show-toplevel` + cd $projDir celery multi stopwait worker1 -A proj -l info \ diff --git a/bin/venv_init.sh b/bin/venv_init.sh index f241801..1bf7cc6 100755 --- a/bin/venv_init.sh +++ b/bin/venv_init.sh @@ -1,8 +1,8 @@ #!/usr/bin/env bash - +projDir=`git rev-parse --show-toplevel` # you should first install virtualenv like `pip install --user virtualenv` -virtualenv --no-site-packages ../env -source ../env/bin/activate -pip3 install -r ../requirements.txt +virtualenv --no-site-packages $projDir/env +source $projDir/env/bin/activate +pip3 install -r $projDir/requirements.txt deactivate