@@ -24,28 +24,107 @@ source tb_tables.config
2424# $7 --> Binlog position file
2525#
2626# ############################################################
27- run_listener () {
27+ function run_listener() {
2828
2929 (clickhouse-mysql --src-server-id=$5 --src-wait --src-resume --binlog-position-file $7 --nice-pause=1 --src-host=$SOURCE_HOST --src-port=$SOURCE_PORT --src-user=$SOURCE_USER --src-password=$SOURCE_PASSWD --src-schemas=$1 --src-tables=$2 --dst-host=$DESTINATION_HOST --dst-schema=$3 --dst-table=$4 --log-level=$LOG_LEVEL --pump-data 2>> $6 )&
3030
3131}
3232
33- run_listener " movida_preproduction" " schedulings" " $TB_DATABASE " " $SCHEDULINGS_TABLE " " 91" " out-schedulings.log" " bl-pos-schedulings"
34- echo $! > $PID_LOG_FILE
33+ function run_schedulings() {
34+ if [ $binlog == " true" ]; then
35+ rm " bl-pos-collections"
36+ fi
3537
36- run_listener " movida_preproduction" " platforms " " $TB_DATABASE " " $PLATFORMS_TABLE " " 92 " " out-platforms .log" " bl-pos-platforms "
37- echo $! > > $PID_LOG_FILE
38+ run_listener " movida_preproduction" " schedulings " " $TB_DATABASE " " $SCHEDULINGS_TABLE " " 91 " " out-schedulings .log" " bl-pos-schedulings "
39+ echo $! > $PID_LOG_FILE
3840
39- run_listener " movida_preproduction" " titles" " $TB_DATABASE " " $TITLES_TABLE " " 93" " out-titles.log" " bl-pos-titles"
40- echo $! >> $PID_LOG_FILE
41+ }
42+
43+ function run_platforms() {
44+ if [ $binlog == " true" ]; then
45+ rm " bl-pos-collections"
46+ fi
47+
48+ run_listener " movida_preproduction" " platforms" " $TB_DATABASE " " $PLATFORMS_TABLE " " 92" " out-platforms.log" " bl-pos-platforms"
49+ echo $! >> $PID_LOG_FILE
50+
51+ }
52+
53+ function run_titles() {
54+ if [ $binlog == " true" ]; then
55+ rm " bl-pos-collections"
56+ fi
57+
58+ run_listener " movida_preproduction" " titles" " $TB_DATABASE " " $TITLES_TABLE " " 93" " out-titles.log" " bl-pos-titles"
59+ echo $! >> $PID_LOG_FILE
60+ }
61+
62+ function run_assets() {
63+ if [ $binlog == " true" ]; then
64+ rm " bl-pos-collections"
65+ fi
4166
42- run_listener " movida_preproduction" " assets" " $TB_DATABASE " " $ASSETS_TABLE " " 94" " out-assets.log" " bl-pos-assets"
43- echo $! >> $PID_LOG_FILE
67+ run_listener " movida_preproduction" " assets" " $TB_DATABASE " " $ASSETS_TABLE " " 94" " out-assets.log" " bl-pos-assets"
68+ echo $! >> $PID_LOG_FILE
69+ }
70+
71+ function run_features() {
72+ if [ $binlog == " true" ]; then
73+ rm " bl-pos-collections"
74+ fi
75+
76+ run_listener " movida_preproduction" " features" " $TB_DATABASE " " $FEATURES_TABLE " " 95" " out-features.log" " bl-pos-features"
77+ echo $! >> $PID_LOG_FILE
78+ }
79+
80+ function run_collections() {
81+ if [ $binlog == " true" ]; then
82+ rm " bl-pos-collections"
83+ fi
84+
85+ run_listener " movida_preproduction" " collection_entries" " $TB_DATABASE " " $COLLECTIONS_TABLE " " 96" " out-collections.log" " bl-pos-collections"
86+ echo $! >> $PID_LOG_FILE
87+ }
88+
89+ function usage {
90+ echo " usage: $0 -d datasource [-b clean_binlog]"
91+ echo " -d datasource datasource to syn. Use all for synchronizing all available datasources."
92+ echo " - all"
93+ echo " - schedulings"
94+ echo " - platforms"
95+ echo " - titles"
96+ echo " - assets"
97+ echo " - features"
98+ echo " - collections"
99+ echo " -b clean_binlog clean binlog before running (true | false) False by default"
100+ exit -1
101+ }
44102
45- run_listener " movida_preproduction" " features" " $TB_DATABASE " " $FEATURES_TABLE " " 95" " out-features.log" " bl-pos-features"
46- echo $! >> $PID_LOG_FILE
103+ datasource=" NONE"
104+ while getopts d:b: flag
105+ do
106+ case " ${flag} " in
107+ d) datasource=${OPTARG} ;;
108+ b) binlog=${OPTARG} ;;
109+ esac
110+ done
47111
48- run_listener " movida_preproduction" " collection_entries" " $TB_DATABASE " " $COLLECTIONS_TABLE " " 96" " out-collections.log" " bl-pos-collections"
49- echo $! >> $PID_LOG_FILE
112+ case " ${datasource} " in
113+ NONE) usage;;
114+ all) run_schedulings binlog
115+ run_platforms binlog
116+ run_titles binlog
117+ run_assets binlog
118+ run_features binlog
119+ run_collections binlog
120+ ;;
121+ schedulings) run_schedulings binlog;;
122+ platforms) run_platforms binlog;;
123+ titles) run_titles binlog;;
124+ assets) run_assets binlog;;
125+ features) run_features binlog;;
126+ collections) run_collections binlog;;
127+ * ) usage;;
128+ esac
50129
51130echo " PID processes in $PID_LOG_FILE "
0 commit comments