Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4736 rajveer 1
#!/bin/bash
2
 
3
# resolve links - $0 may be a softlink
4
PRG="$0"
5
 
6
while [ -h "$PRG" ]; do
7
  ls=`ls -ld "$PRG"`
8
  link=`expr "$ls" : '.*-> \(.*\)$'`
9
  if expr "$link" : '/.*' > /dev/null; then
10
    PRG="$link"
11
  else
12
    PRG=`dirname "$PRG"`/"$link"
13
  fi
14
done
15
 
16
# Get standard environment variables
17
PRGDIR=`dirname "$PRG"`
18
 
19
if [ $# -ne 2 ]
20
then
21
	echo "Usage: $0 solr_home tomcate_home"
22
	exit 1
23
fi
24
 
25
SOLR_HOME=$1
26
TOMCAT_HOME=$2
27
PROJECT_DIR="${PRGDIR}/../../../../.."
28
#for i in 1 2 3 4 5;
29
#do
30
#	PROJECT_DIR=`dirname "${PROJECT_DIR}"`
31
#done
32
COMMON_DIR="${PROJECT_DIR}/Common"
33
DB_DIR="${PRGDIR}/../db"
34
MAVEN_REPO="${HOME}/.m2/repository"
35
 
36
DATE=`date +%Y-%b-%d_%Hh%Mm`
37
LOGERR=error-${DATE}.log
38
 
39
touch ${LOGERR}
40
exec 7>&2           # Link file descriptor #7 with stderr.
41
                    # Saves stderr.
42
exec 2> ${LOGERR}     # stderr replaced with file ${LOGERR}.
43
 
44
echo "Creating test databases"
45
echo "======================================================================="
46
# create databases
47
mysql -uroot -pshop2020 < ${DB_DIR}/create-databases.sql
48
 
49
echo "Created test databases"
50
echo "======================================================================="
51
 
52
echo "Starting python services"
53
echo "======================================================================="
54
#start services
55
export PYTHONPATH=$PROJECT_DIR/PyProj/src:/usr/lib/pymodules/python2.6:/usr/lib/pymodules/python2.6/gtk-2.0:/usr/lib/python2.6:/usr/lib/python2.6/dist-packages:/usr/lib/python2.6/dist-packages/PIL:/usr/lib/python2.6/dist-packages/gst-0.10:/usr/lib/python2.6/dist-packages/gtk-2.0:/usr/lib/python2.6/lib-dynload:/usr/lib/python2.6/lib-tk:/usr/lib/python2.6/plat-linux2:/usr/local/lib/python2.6/dist-packages:/usr/local/lib/python2.6/dist-packages/Elixir-0.7.1-py2.6.egg
56
 
57
killall -9 python2.6
58
sleep 5
59
/usr/bin/python2.6 -u $PROJECT_DIR/PyProj/src/shop2020/config/ConfigServer.py -e LOCAL_TESTING -f $PROJECT_DIR/PyProj/src/shop2020/config/resources/shop2020.cfg > /tmp/config.log 2>&1 &
60
/usr/bin/python2.6 -u $PROJECT_DIR/PyProj/src/shop2020/model/v1/catalog/CatalogServer.py > /tmp/catalog.log 2>&1 &
61
/usr/bin/python2.6 -u $PROJECT_DIR/PyProj/src/shop2020/model/v1/user/UserContextServer.py > /tmp/user.log 2>&1 &
62
/usr/bin/python2.6 -u $PROJECT_DIR/PyProj/src/shop2020/model/v1/order/TransactionServer.py > /tmp/order.log 2>&1 &
63
/usr/bin/python2.6 -u $PROJECT_DIR/PyProj/src/shop2020/logistics/service/LogisticsServer.py > /tmp/logistics.log 2>&1 &
64
/usr/bin/python2.6 -u $PROJECT_DIR/PyProj/src/shop2020/helpers/impl/HelperServer.py >  /tmp/helpers.log 2>&1 &
65
 
66
sleep 10 # promotion server also uses user dataservice which causes conflict with user service. Add sleep to let user service t create tables first.
67
/usr/bin/python2.6 -u $PROJECT_DIR/PyProj/src/shop2020/model/v1/user/PromotionServer.py > /tmp/promotion.log 2>&1 &
68
 
69
echo "Started python services"
70
echo "======================================================================="
71
 
72
 
73
sleep 5
74
echo "Insert test-data in databases"
75
echo "======================================================================="
76
mysql -uroot -pshop2020 catalog_test < ${DB_DIR}/catalog.sql
77
mysql -uroot -pshop2020 helper_test < ${DB_DIR}/helper.sql
78
mysql -uroot -pshop2020 logistics_test < ${DB_DIR}/logistics.sql
79
mysql -uroot -pshop2020 payment_test < ${DB_DIR}/payment.sql
80
mysql -uroot -pshop2020 transaction_test < ${DB_DIR}/transaction.sql
81
mysql -uroot -pshop2020 user_test < ${DB_DIR}/user.sql
82
 
83
echo "Starting python services after data restore"
84
echo "======================================================================="
85
killall -9 python2.6
86
sleep 5
87
/usr/bin/python2.6 -u $PROJECT_DIR/PyProj/src/shop2020/config/ConfigServer.py -e LOCAL_TESTING -f $PROJECT_DIR/PyProj/src/shop2020/config/resources/shop2020.cfg > /tmp/config.log 2>&1 &
88
/usr/bin/python2.6 -u $PROJECT_DIR/PyProj/src/shop2020/model/v1/catalog/CatalogServer.py > /tmp/catalog.log 2>&1 &
89
/usr/bin/python2.6 -u $PROJECT_DIR/PyProj/src/shop2020/model/v1/user/UserContextServer.py > /tmp/user.log 2>&1 &
90
/usr/bin/python2.6 -u $PROJECT_DIR/PyProj/src/shop2020/model/v1/order/TransactionServer.py > /tmp/order.log 2>&1 &
91
/usr/bin/python2.6 -u $PROJECT_DIR/PyProj/src/shop2020/logistics/service/LogisticsServer.py > /tmp/logistics.log 2>&1 &
92
/usr/bin/python2.6 -u $PROJECT_DIR/PyProj/src/shop2020/helpers/impl/HelperServer.py >  /tmp/helpers.log 2>&1 &
93
/usr/bin/python2.6 -u $PROJECT_DIR/PyProj/src/shop2020/model/v1/user/PromotionServer.py > /tmp/promotion.log 2>&1 &
94
 
95
echo "Started python services after data restore"
96
echo "======================================================================="
97
 
98
#start payment service
99
MAVEN_REPO="${HOME}/.m2/repository"
100
 
101
/usr/bin/java -cp .:${PROJECT_DIR}/PaymentService/src/test/resources:${MAVEN_REPO}/in/shop2020/PaymentService/1.0-SNAPSHOT/PaymentService-1.0-SNAPSHOT.jar:${MAVEN_REPO}/commons-daemon/commons-daemon/1.0.1/commons-daemon-1.0.1.jar:${MAVEN_REPO}/org/apache/thrift/libthrift/0.7.0/libthrift-0.7.0.jar:${MAVEN_REPO}/commons-lang/commons-lang/2.5/commons-lang-2.5.jar:${MAVEN_REPO}/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar:${MAVEN_REPO}/org/apache/httpcomponents/httpclient/4.0.1/httpclient-4.0.1.jar:${MAVEN_REPO}/org/apache/httpcomponents/httpcore/4.0.1/httpcore-4.0.1.jar:${MAVEN_REPO}/commons-codec/commons-codec/1.3/commons-codec-1.3.jar:${MAVEN_REPO}/readonly/apache/log4j/1.2.16/log4j-1.2.16.jar:${MAVEN_REPO}/readonly/apache/commons-logging/1.0.4/commons-logging-1.0.4.jar:${MAVEN_REPO}/in/shop2020/ThriftConfig/1.0-SNAPSHOT/ThriftConfig-1.0-SNAPSHOT.jar:${MAVEN_REPO}/readonly/slf4j/slf4j-api/1.5.8/slf4j-api-1.5.8.jar:${MAVEN_REPO}/readonly/slf4j/slf4j-simple/1.5.8/slf4j-simple-1.5.8.jar:${MAVEN_REPO}/in/shop2020/Common/1.0-SNAPSHOT/Common-1.0-SNAPSHOT.jar:${MAVEN_REPO}/readonly/apache/commons-lang/2.4/commons-lang-2.4.jar:${MAVEN_REPO}/org/json/json/20090211/json-20090211.jar:${MAVEN_REPO}/javax/mail/mail/1.4/mail-1.4.jar:${MAVEN_REPO}/javax/activation/activation/1.1/activation-1.1.jar:${MAVEN_REPO}/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1.jar:${MAVEN_REPO}/org/slf4j/slf4j-log4j12/1.6.1/slf4j-log4j12-1.6.1.jar:${MAVEN_REPO}/log4j/log4j/1.2.16/log4j-1.2.16.jar:${MAVEN_REPO}/org/mybatis/mybatis-spring/1.0.0/mybatis-spring-1.0.0.jar:${MAVEN_REPO}/org/mybatis/mybatis/3.0.4/mybatis-3.0.4.jar:${MAVEN_REPO}/cglib/cglib/2.2/cglib-2.2.jar:${MAVEN_REPO}/commons-pool/commons-pool/1.5.6/commons-pool-1.5.6.jar:${MAVEN_REPO}/commons-dbcp/commons-dbcp/1.4/commons-dbcp-1.4.jar:${MAVEN_REPO}/aopalliance/aopalliance/1.0/aopalliance-1.0.jar:${MAVEN_REPO}/org/springframework/spring-aop/3.0.5.RELEASE/spring-aop-3.0.5.RELEASE.jar:${MAVEN_REPO}/org/springframework/spring-asm/3.0.5.RELEASE/spring-asm-3.0.5.RELEASE.jar:${MAVEN_REPO}/org/springframework/spring-beans/3.0.5.RELEASE/spring-beans-3.0.5.RELEASE.jar:${MAVEN_REPO}/org/springframework/spring-context/3.0.5.RELEASE/spring-context-3.0.5.RELEASE.jar:${MAVEN_REPO}/org/springframework/spring-core/3.0.5.RELEASE/spring-core-3.0.5.RELEASE.jar:${MAVEN_REPO}/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar:${MAVEN_REPO}/org/springframework/spring-expression/3.0.5.RELEASE/spring-expression-3.0.5.RELEASE.jar:${MAVEN_REPO}/org/springframework/spring-jdbc/3.0.5.RELEASE/spring-jdbc-3.0.5.RELEASE.jar:${MAVEN_REPO}/org/springframework/spring-tx/3.0.5.RELEASE/spring-tx-3.0.5.RELEASE.jar:${MAVEN_REPO}/asm/asm/3.1/asm-3.1.jar:${MAVEN_REPO}/mysql/mysql-connector-java/5.1.16/mysql-connector-java-5.1.16.jar:${MAVEN_REPO}/readonly/hdfc-payment/2.0/hdfc-payment-2.0.jar:/usr/share/java/commons-daemon.jar in.shop2020.payment.service.PaymentServer >> /tmp/payment.java.log 2>&1 &
102
 
103
echo "Started payment service"
104
echo "======================================================================="
105
 
106
echo "Starting Tomcat"
107
echo "======================================================================="
108
# deploy war and start tomcat
109
${TOMCAT_HOME}/bin/catalina.sh stop
110
echo $TOMCAT_HOME/webapps/ROOT*
111
rm -rf $TOMCAT_HOME/webapps/ROOT*
112
cp ${MAVEN_REPO}/in/shop2020/Website/1.0-SNAPSHOT/Website-1.0-SNAPSHOT.war $TOMCAT_HOME/webapps/ROOT.war
113
${TOMCAT_HOME}/bin/catalina.sh start
114
sleep 5
115
 
116
echo "Copying static content"
117
echo "======================================================================="
118
# static content
119
rm -rf ${TOMCAT_HOME}/webapps/export/html
120
cp -r ${PRGDIR}/../static/html ${TOMCAT_HOME}/webapps/export/
121
cp -r ${PRGDIR}/../static/media/* ${TOMCAT_HOME}/webapps/ROOT/images/
122
mv ${TOMCAT_HOME}/webapps/ROOT/images/static ${TOMCAT_HOME}/webapps/ROOT/images/media
123
 
124
echo "Started tomcat"
125
echo "======================================================================="
126
 
127
 
128
echo "Stopping and starting Solr service at `date +%H:%M:%S`"
129
echo "======================================================================="
130
# solr
131
ps aux | grep start.jar | grep -v grep | awk '{print $2}' | xargs kill -9
132
cd $SOLR_HOME/example/
133
java -jar start.jar >/tmp/solr.log &
134
sleep 15
135
echo "Solr started at `date +%H:%M:%S`"
136
echo "======================================================================="
137
 
138
echo "Posting data to Solr at `date +%H:%M:%S`"
139
cd $SOLR_HOME/example/exampledocs/
140
./deleteAll.sh
141
java -Durl=http://localhost:8993/solr/update -jar post.jar ${PRGDIR}/../solr/*irdata_solr.xml
142
echo "Done posting data"
143
 
144
#Clean up IO redirection
145
exec 2>&7 7>&-      # Restore stdout and close file descriptor #7.