Automatically start redis_levelDB with the correct date

pull/136/head
= 2017-08-23 10:16:56 +02:00
parent 64ec44085d
commit d632335760
3 changed files with 19 additions and 24 deletions

View File

@ -65,36 +65,26 @@ function launching_redis {
} }
function launching_lvldb { function launching_lvldb {
#Want to launch more level_db?
lvdbhost='127.0.0.1' lvdbhost='127.0.0.1'
lvdbdir="${AIL_HOME}/LEVEL_DB_DATA/" 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 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" screen -dmS "LevelDB"
sleep 0.1 sleep 0.1
echo -e $GREEN"\t* Launching Levels DB servers"$DEFAULT 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'
#Launch a DB for each dir
# For Curve for pathDir in $lvdbdir*/ ; do
sleep 0.1 yDir=$(basename "$pathDir")
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
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'
screen -S "LevelDB" -X screen -t "3017" bash -c 'redis-leveldb -H '$lvdbhost' -D '$lvdbdir'3017/ -P '$dbC1_y' -M '$nb_db'; read x' done
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'
} }
function launching_logs { function launching_logs {

View File

@ -25,12 +25,13 @@ def main():
parser.add_argument('-f', type=str, metavar="filename", default="figure", parser.add_argument('-f', type=str, metavar="filename", default="figure",
help='The absolute path name of the "figure.png"', help='The absolute path name of the "figure.png"',
action='store') action='store')
parser.add_argument('-y', '--year', type=int, required=False, default=None, help='The date related to the DB')
args = parser.parse_args() args = parser.parse_args()
# REDIS # # REDIS #
# port generated automatically depending on the date # 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( r_serv = redis.StrictRedis(
host=cfg.get("Redis_Level_DB_Hashs", "host"), host=cfg.get("Redis_Level_DB_Hashs", "host"),
port=curYear, port=curYear,

View File

@ -7,9 +7,11 @@
import ConfigParser import ConfigParser
import redis import redis
import os import os
from datetime import datetime
# FLASK # # FLASK #
app = None app = None
curYear = None #can be set to fit the needs, Correspond to the level-DB year to be used
# CONFIG # # CONFIG #
configfile = os.path.join(os.environ['AIL_BIN'], 'packages/config.cfg') 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"), port=cfg.getint("Redis_Level_DB_Trending", "port"),
db=cfg.getint("Redis_Level_DB_Trending", "db")) 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( r_serv_db = redis.StrictRedis(
host=cfg.get("Redis_Level_DB", "host"), host=cfg.get("Redis_Level_DB", "host"),
port=cfg.getint("Redis_Level_DB", "port"), port=curYear,
db=cfg.getint("Redis_Level_DB", "db")) db=cfg.getint("Redis_Level_DB", "db"))
r_serv_sentiment = redis.StrictRedis( r_serv_sentiment = redis.StrictRedis(