mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-10 08:38:28 +00:00
Automatically start redis_levelDB with the correct date
This commit is contained in:
parent
64ec44085d
commit
d632335760
3 changed files with 19 additions and 24 deletions
|
@ -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
|
||||
#Launch a DB for each dir
|
||||
for pathDir in $lvdbdir*/ ; do
|
||||
yDir=$(basename "$pathDir")
|
||||
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'
|
||||
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 {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue