From 198ee97d90697ac579de856ce7e2ac42a2f50a83 Mon Sep 17 00:00:00 2001 From: Terrtia Date: Wed, 19 Dec 2018 11:41:01 +0100 Subject: [PATCH] chg: [update 1.5] add update bash --- bin/LAUNCH.sh | 15 +++++++++------ update/v1.5/Update.py | 16 ---------------- update/v1.5/Update.sh | 39 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 47 insertions(+), 23 deletions(-) diff --git a/bin/LAUNCH.sh b/bin/LAUNCH.sh index 5467396f..2e6dd6e6 100755 --- a/bin/LAUNCH.sh +++ b/bin/LAUNCH.sh @@ -16,7 +16,6 @@ export AIL_HOME="${DIR}" cd ${AIL_HOME} if [ -e "${DIR}/AILENV/bin/python" ]; then - echo "AIL-framework virtualenv seems to exist, good" ENV_PY="${DIR}/AILENV/bin/python" else echo "Please make sure you have a AIL-framework environment, au revoir" @@ -348,11 +347,15 @@ function launch_feeder { function killall { if [[ $isredis || $isardb || $islogged || $isqueued || $isscripted || $isflasked || $isfeeded ]]; then - echo -e $GREEN"Gracefully closing redis servers"$DEFAULT - shutting_down_redis; - sleep 0.2 - echo -e $GREEN"Gracefully closing ardb servers"$DEFAULT - shutting_down_ardb; + if [[ $isredis ]]; then + echo -e $GREEN"Gracefully closing redis servers"$DEFAULT + shutting_down_redis; + sleep 0.2 + fi + if [[ $isardb ]]; then + echo -e $GREEN"Gracefully closing ardb servers"$DEFAULT + shutting_down_ardb; + fi echo -e $GREEN"Killing all"$DEFAULT kill $isredis $isardb $islogged $isqueued $isscripted $isflasked $isfeeded sleep 0.2 diff --git a/update/v1.5/Update.py b/update/v1.5/Update.py index b330672d..2622976f 100755 --- a/update/v1.5/Update.py +++ b/update/v1.5/Update.py @@ -91,19 +91,11 @@ if __name__ == '__main__': for key in r_serv_metadata.scan_iter(key_to_rename): temp = [] for zset_key, value in r_serv_metadata.zscan_iter(key, '*{}*'.format(PASTES_FOLDER)): - #print(key) - #print(zset_key) - #print(value) new_key = zset_key.replace(PASTES_FOLDER, '', 1) index = index +1 temp.append((key, zset_key)) keys_to_add.append((key, new_key, value)) if 0 < len(temp) < r_serv_metadata.zcard(key): - #print(key) - #print(len(temp)) - #print(temp) - #print(r_serv_metadata.zcard(key)) - #print('---------------') zkeys_to_remove.extend(temp) else: keys_to_remove.append(key) @@ -183,14 +175,6 @@ if __name__ == '__main__': end = time.time() - '''' - for key in r_serv_metadata.scan_iter('*{}*'.format(PASTES_FOLDER)): - if not 'dup:' in key: - if not 'paste_i2p_external_links:' in key: - if not 'base64:' in key: - print(key) - ''' - print('Updating ARDB_Metadata Done => {} paths: {} s'.format(index, end - start)) print() diff --git a/update/v1.5/Update.sh b/update/v1.5/Update.sh index e69e3b31..f329c7c5 100755 --- a/update/v1.5/Update.sh +++ b/update/v1.5/Update.sh @@ -1,4 +1,41 @@ #!/bin/bash -echo $AIL_HOME +[ -z "$AIL_HOME" ] && echo "Needs the env var AIL_HOME. Run the script from the virtual environment." && exit 1; +[ -z "$AIL_REDIS" ] && echo "Needs the env var AIL_REDIS. Run the script from the virtual environment." && exit 1; +[ -z "$AIL_ARDB" ] && echo "Needs the env var AIL_ARDB. Run the script from the virtual environment." && exit 1; +[ -z "$AIL_BIN" ] && echo "Needs the env var AIL_ARDB. Run the script from the virtual environment." && exit 1; +[ -z "$AIL_FLASK" ] && echo "Needs the env var AIL_FLASK. Run the script from the virtual environment." && exit 1; +export PATH=$AIL_HOME:$PATH +export PATH=$AIL_REDIS:$PATH +export PATH=$AIL_ARDB:$PATH +export PATH=$AIL_BIN:$PATH +export PATH=$AIL_FLASK:$PATH + +echo "Killing all screens ..." +bash -c "bash ${AIL_BIN}/LAUNCH.sh -k" +echo "" +echo "Starting ARDB ..." +bash -c "bash ${AIL_BIN}/launch_ardb.sh" + +flag_ardb=true +while $flag_ardb; do + sleep 1 + bash -c "bash ${AIL_BIN}/check_ardb.sh" + if [ $? == 0 ]; then + flag_ardb=false + else + echo "ARDB not available, waiting 5s before retry" + sleep 5 + fi +done + +echo "" +bash -c "python ${AIL_HOME}/update/v1.5/Update.py" + +echo "Shutting down ARDB ..." +bash -c "bash ${AIL_BIN}/LAUNCH.sh -k" + +echo "" + +exit 0