comparison backend/contrib/import_river.sh @ 7728:c842ebb0db86

Importer: fix logging in import_river.sh.
author Tom Gottfried <tom@intevation.de>
date Thu, 16 Jan 2014 12:02:54 +0100
parents 5e621410db05
children 06a4071143b0
comparison
equal deleted inserted replaced
7727:3d772f52080a 7728:c842ebb0db86
68 -h, --host=<host> Connect to database on host <host>. 68 -h, --host=<host> Connect to database on host <host>.
69 Default: $DEFAULT_HOST 69 Default: $DEFAULT_HOST
70 -p, --port=<number> Use port number <number>. Default: $DEFAULT_PORT 70 -p, --port=<number> Use port number <number>. Default: $DEFAULT_PORT
71 -d, --db-name=<database_name> Name of the database / backend. Default: $DEFAULT_BACKEND_NAME 71 -d, --db-name=<database_name> Name of the database / backend. Default: $DEFAULT_BACKEND_NAME
72 -l, --log-dir=<directory> Directory in which to create the log files. 72 -l, --log-dir=<directory> Directory in which to create the log files.
73 Default: $LOG_DIR 73 Default: $PWD/logs
74 --postgres Database is PostgreSQL 74 --postgres Database is PostgreSQL
75 --skip-hydro Skip import of hydrological data 75 --skip-hydro Skip import of hydrological data
76 --skip-morpho Skip import of morphological data 76 --skip-morpho Skip import of morphological data
77 --skip-geo Skip import of geographic data 77 --skip-geo Skip import of geographic data
78 --skip-prf Skip import of cross section data 78 --skip-prf Skip import of cross section data
79 EOF 79 EOF
80 exit 0 80 exit 0
81 } 81 }
82 82
83 OPTS=`getopt -o ?u:w:h:p:d: \ 83 OPTS=`getopt -o ?u:w:h:p:d:l: \
84 -l help,username:,password:,host:,port:,db-name:,skip-hydro,skip-morpho,skip-geo,skip-prf,postgres \ 84 -l help,username:,password:,host:,port:,db-name:,log-dir:,skip-hydro,skip-morpho,skip-geo,skip-prf,postgres \
85 -n $0 -- "$@"` 85 -n $0 -- "$@"`
86 if [ $? != 0 ] ; then usage; fi 86 if [ $? != 0 ] ; then usage; fi
87 eval set -- "$OPTS" 87 eval set -- "$OPTS"
88 while true ; do 88 while true ; do
89 case "$1" in 89 case "$1" in
144 DBHOST=$DEFAULT_HOST 144 DBHOST=$DEFAULT_HOST
145 fi 145 fi
146 if [ -z $BACKEND_NAME ]; then 146 if [ -z $BACKEND_NAME ]; then
147 BACKEND_NAME=$DEFAULT_BACKEND_NAME 147 BACKEND_NAME=$DEFAULT_BACKEND_NAME
148 fi 148 fi
149 if [ -z $LOGDIR ]; then 149 if [ -z $LOG ]; then
150 LOG=$DEFAULT_LOG 150 LOG=$DEFAULT_LOG
151 fi 151 fi
152 152
153 if [ $# != 1 ]; then 153 if [ $# != 1 ]; then
154 usage 154 usage
161 GEW_FILE="$1" 161 GEW_FILE="$1"
162 RIVER_NAME=$(grep "Gew.sser" "$1" | sed 's/Gew.sser: //') 162 RIVER_NAME=$(grep "Gew.sser" "$1" | sed 's/Gew.sser: //')
163 DATE=$(date +%Y.%m.%d_%H%M) 163 DATE=$(date +%Y.%m.%d_%H%M)
164 LOG_DIR=${LOG}/`basename $GEW_FILE .gew`-$DATE 164 LOG_DIR=${LOG}/`basename $GEW_FILE .gew`-$DATE
165 mkdir -p ${LOG_DIR} 165 mkdir -p ${LOG_DIR}
166
167 cat > "$LOG_DIR/log4j.properties" << "EOF"
168 log4j.rootLogger=DEBUG, IMPORTER
169 log4j.appender.IMPORTER.layout=org.apache.log4j.PatternLayout
170 log4j.appender.IMPORTER.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
171 log4j.appender.IMPORTER=org.apache.log4j.RollingFileAppender
172 log4j.appender.IMPORTER.File=./import.log
173 log4j.appender.IMPORTER.MaxFileSize=100000KB
174 log4j.appender.IMPORTER.MaxBackupIndex=10
175 EOF
166 176
167 if [ "$POSTGRES" = "TRUE" ]; then 177 if [ "$POSTGRES" = "TRUE" ]; then
168 JAR=$(echo "$JAR" | sed 's/importer/importer_psql/') 178 JAR=$(echo "$JAR" | sed 's/importer/importer_psql/')
169 if [ ! -r "$JAR" ]; then 179 if [ ! -r "$JAR" ]; then
170 echo "Could not find Postgres importer $JAR" 180 echo "Could not find Postgres importer $JAR"
187 197
188 import_hydro(){ 198 import_hydro(){
189 LOG_FILE=${LOG_DIR}/hydro.log 199 LOG_FILE=${LOG_DIR}/hydro.log
190 echo Importing Hydrological data. 200 echo Importing Hydrological data.
191 echo Logging into: $LOG_FILE 201 echo Logging into: $LOG_FILE
192 sed 's!./import.log!'"$LOG_FILE"'!' conf/log4j.properties > $LOG_DIR/log4j.properties 202 sed -i 's!\(log4j.appender.IMPORTER.File=\).*!\1'"$LOG_FILE"'!' \
203 $LOG_DIR/log4j.properties
193 java -jar \ 204 java -jar \
194 -Xmx$MIN_MEMORY \ 205 -Xmx$MIN_MEMORY \
195 -server \ 206 -server \
196 -Dlog4j.configuration=file://$LOG_DIR/log4j.properties \ 207 -Dlog4j.configuration=file://$LOG_DIR/log4j.properties \
197 -Dflys.backend.user=$DBUSER \ 208 -Dflys.backend.user=$DBUSER \
234 245
235 import_morpho(){ 246 import_morpho(){
236 LOG_FILE=${LOG_DIR}/morpho.log 247 LOG_FILE=${LOG_DIR}/morpho.log
237 echo Importing Morphological data. 248 echo Importing Morphological data.
238 echo Logging into: $LOG_FILE 249 echo Logging into: $LOG_FILE
239 sed 's!./import.log!'"$LOG_FILE"'!' conf/log4j.properties > $LOG_DIR/log4j.properties 250 sed -i 's!\(log4j.appender.IMPORTER.File=\).*!\1'"$LOG_FILE"'!' \
251 $LOG_DIR/log4j.properties
240 java -jar \ 252 java -jar \
241 -Xmx$MIN_MEMORY \ 253 -Xmx$MIN_MEMORY \
242 -server \ 254 -server \
243 -Dlog4j.configuration=file://$LOG_DIR/log4j.properties \ 255 -Dlog4j.configuration=file://$LOG_DIR/log4j.properties \
244 -Dflys.backend.user=$DBUSER \ 256 -Dflys.backend.user=$DBUSER \
281 293
282 import_prf(){ 294 import_prf(){
283 LOG_FILE=${LOG_DIR}/prf.log 295 LOG_FILE=${LOG_DIR}/prf.log
284 echo Importing cross section data. 296 echo Importing cross section data.
285 echo Logging into: $LOG_FILE 297 echo Logging into: $LOG_FILE
286 sed 's!./import.log!'"$LOG_FILE"'!' conf/log4j.properties > $LOG_DIR/log4j.properties 298 sed -i 's!\(log4j.appender.IMPORTER.File=\).*!\1'"$LOG_FILE"'!' \
299 $LOG_DIR/log4j.properties
287 java -jar \ 300 java -jar \
288 -Xmx$MIN_MEMORY \ 301 -Xmx$MIN_MEMORY \
289 -server \ 302 -server \
290 -Dlog4j.configuration=file://$LOG_DIR/log4j.properties \ 303 -Dlog4j.configuration=file://$LOG_DIR/log4j.properties \
291 -Dflys.backend.user=$DBUSER \ 304 -Dflys.backend.user=$DBUSER \

http://dive4elements.wald.intevation.org