@@ -24,28 +24,107 @@ source tb_tables.config
24
24
# $7 --> Binlog position file
25
25
#
26
26
# ############################################################
27
- run_listener () {
27
+ function run_listener() {
28
28
29
29
(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 )&
30
30
31
31
}
32
32
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
35
37
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
38
40
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
41
66
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
+ }
44
102
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
47
111
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
50
129
51
130
echo " PID processes in $PID_LOG_FILE "
0 commit comments