From d6323357601713dc5fd9abbc57dc6ae8d03e2c7f Mon Sep 17 00:00:00 2001 From: = Date: Wed, 23 Aug 2017 10:16:56 +0200 Subject: [PATCH] Automatically start redis_levelDB with the correct date --- bin/LAUNCH.sh | 34 ++++++++++++--------------------- bin/Repartition_graph.py | 3 ++- var/www/modules/Flask_config.py | 6 +++++- 3 files changed, 19 insertions(+), 24 deletions(-) diff --git a/bin/LAUNCH.sh b/bin/LAUNCH.sh index 05c408b0..227d3a9b 100755 --- a/bin/LAUNCH.sh +++ b/bin/LAUNCH.sh @@ -65,36 +65,26 @@ function launching_redis { } function launching_lvldb { - #Want to launch more level_db? lvdbhost='127.0.0.1' lvdbdir="${AIL_HOME}/LEVEL_DB_DATA/" - db1_y='2016' - db2_y='2017' - dbn_y=`date +%Y` - - dbC1_y='3016' - dbCn_y=30`date +%y` nb_db=13 + db_y=`date +%Y` + #Verify that a dir with the correct year exists, create it otherwise + if [ ! -d "$lvdbdir$db_y" ]; then + mkdir -p "$db_y" + fi + screen -dmS "LevelDB" sleep 0.1 echo -e $GREEN"\t* Launching Levels DB servers"$DEFAULT - #Add lines here with appropriates options. - sleep 0.1 - screen -S "LevelDB" -X screen -t "2016" bash -c 'redis-leveldb -H '$lvdbhost' -D '$lvdbdir'2016/ -P '$db1_y' -M '$nb_db'; read x' - sleep 0.1 - screen -S "LevelDB" -X screen -t "2017" bash -c 'redis-leveldb -H '$lvdbhost' -D '$lvdbdir'2017/ -P '$db2_y' -M '$nb_db'; read x' - sleep 0.1 - screen -S "LevelDB" -X screen -t "$dbn_y" bash -c 'redis-leveldb -H '$lvdbhost' -D '$lvdbdir$dbn_y'/ -P '$dbn_y' -M '$nb_db'; read x' - - # For Curve - sleep 0.1 - screen -S "LevelDB" -X screen -t "3016" bash -c 'redis-leveldb -H '$lvdbhost' -D '$lvdbdir'3016/ -P '$dbC1_y' -M '$nb_db'; read x' - sleep 0.1 - screen -S "LevelDB" -X screen -t "3017" bash -c 'redis-leveldb -H '$lvdbhost' -D '$lvdbdir'3017/ -P '$dbC1_y' -M '$nb_db'; read x' - sleep 0.1 - screen -S "LevelDB" -X screen -t "$dbCn_y" bash -c 'redis-leveldb -H '$lvdbhost' -D '$lvdbdir$dbCn_y'/ -P '$dbCn_y' -M '$nb_db'; read x' + #Launch a DB for each dir + for pathDir in $lvdbdir*/ ; do + yDir=$(basename "$pathDir") + sleep 0.1 + screen -S "LevelDB" -X screen -t "$yDir" bash -c 'redis-leveldb -H '$lvdbhost' -D '$pathDir'/ -P '$yDir' -M '$nb_db'; read x' + done } function launching_logs { diff --git a/bin/Repartition_graph.py b/bin/Repartition_graph.py index a8094bb0..38c5e1b6 100755 --- a/bin/Repartition_graph.py +++ b/bin/Repartition_graph.py @@ -25,12 +25,13 @@ def main(): parser.add_argument('-f', type=str, metavar="filename", default="figure", help='The absolute path name of the "figure.png"', action='store') + parser.add_argument('-y', '--year', type=int, required=False, default=None, help='The date related to the DB') args = parser.parse_args() # REDIS # # port generated automatically depending on the date - curYear = datetime.now().year + curYear = datetime.now().year if args.year is None else args.year r_serv = redis.StrictRedis( host=cfg.get("Redis_Level_DB_Hashs", "host"), port=curYear, diff --git a/var/www/modules/Flask_config.py b/var/www/modules/Flask_config.py index 161e6130..14468fa1 100644 --- a/var/www/modules/Flask_config.py +++ b/var/www/modules/Flask_config.py @@ -7,9 +7,11 @@ import ConfigParser import redis import os +from datetime import datetime # FLASK # app = None +curYear = None #can be set to fit the needs, Correspond to the level-DB year to be used # CONFIG # configfile = os.path.join(os.environ['AIL_BIN'], 'packages/config.cfg') @@ -38,9 +40,11 @@ r_serv_charts = redis.StrictRedis( port=cfg.getint("Redis_Level_DB_Trending", "port"), db=cfg.getint("Redis_Level_DB_Trending", "db")) +# port generated automatically depending on the date +curYear = datetime.now().year if curYear is None else curYear r_serv_db = redis.StrictRedis( host=cfg.get("Redis_Level_DB", "host"), - port=cfg.getint("Redis_Level_DB", "port"), + port=curYear, db=cfg.getint("Redis_Level_DB", "db")) r_serv_sentiment = redis.StrictRedis(