You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by la...@apache.org on 2013/08/14 06:34:26 UTC
git commit: set nhttp as elb default transport and tomcat init script
update
Updated Branches:
refs/heads/master c67e7c5bf -> 0fc815786
set nhttp as elb default transport and tomcat init script update
Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/0fc81578
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/0fc81578
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/0fc81578
Branch: refs/heads/master
Commit: 0fc815786f65de67bff3a0a554668402b461647c
Parents: c67e7c5
Author: Lahiru Sandaruwan <la...@wso2.com>
Authored: Wed Aug 14 10:09:39 2013 +0530
Committer: Lahiru Sandaruwan <la...@wso2.com>
Committed: Wed Aug 14 10:09:39 2013 +0530
----------------------------------------------------------------------
.../distribution/src/main/conf/axis2.xml | 44 ++---
.../init_scripts/tomcat/stratos-init.sh | 164 +++++++++++++++----
2 files changed, 157 insertions(+), 51 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/0fc81578/products/elb/modules/distribution/src/main/conf/axis2.xml
----------------------------------------------------------------------
diff --git a/products/elb/modules/distribution/src/main/conf/axis2.xml b/products/elb/modules/distribution/src/main/conf/axis2.xml
index 130a662..71b4ae7 100755
--- a/products/elb/modules/distribution/src/main/conf/axis2.xml
+++ b/products/elb/modules/distribution/src/main/conf/axis2.xml
@@ -213,7 +213,7 @@
<!-- Transport Ins (Listeners) -->
<!-- ================================================= -->
<!--Default trasnport will be passthrough if you need to change please add it here -->
- <transportReceiver name="http" class="org.apache.synapse.transport.passthru.PassThroughHttpListener">
+ <!--transportReceiver name="http" class="org.apache.synapse.transport.passthru.PassThroughHttpListener">
<parameter name="port">8280</parameter>
<parameter name="non-blocking"> true</parameter>
<parameter name="httpGetProcessor" locked="false">org.wso2.carbon.transport.nhttp.api.PassThroughNHttpGetProcessor</parameter>
@@ -221,10 +221,10 @@
<transportReceiver name="https" class="org.apache.synapse.transport.passthru.PassThroughHttpSSLListener">
<parameter name="port" locked="false">8243</parameter>
<parameter name="non-blocking" locked="false">true</parameter>
- <parameter name="httpGetProcessor" locked="false">org.wso2.carbon.transport.nhttp.api.PassThroughNHttpGetProcessor</parameter>
+ <parameter name="httpGetProcessor" locked="false">org.wso2.carbon.transport.nhttp.api.PassThroughNHttpGetProcessor</parameter-->
<!--parameter name="bind-address" locked="false">hostname or IP address</parameter-->
<!--parameter name="WSDLEPRPrefix" locked="false">https://apachehost:port/somepath</parameter-->
- <parameter name="keystore" locked="false">
+ <!--parameter name="keystore" locked="false">
<KeyStore>
<Location>repository/resources/security/wso2carbon.jks</Location>
<Type>JKS</Type>
@@ -238,28 +238,28 @@
<Type>JKS</Type>
<Password>wso2carbon</Password>
</TrustStore>
- </parameter>
+ </parameter-->
<!--<parameter name="SSLVerifyClient">require</parameter>
supports optional|require or defaults to none -->
- </transportReceiver>
+ <!--/transportReceiver-->
<!-- uncomment for non blocking http transport based on HttpCore + NIO extensions -->
- <!--transportReceiver name="http" class="org.apache.synapse.transport.nhttp.HttpCoreNIOListener">
+ <transportReceiver name="http" class="org.apache.synapse.transport.nhttp.HttpCoreNIOListener">
<parameter name="port" locked="false">8280</parameter>
- <parameter name="non-blocking" locked="false">true</parameter-->
+ <parameter name="non-blocking" locked="false">true</parameter>
<!--parameter name="bind-address" locked="false">hostname or IP address</parameter-->
<!--parameter name="WSDLEPRPrefix" locked="false">https://apachehost:port/somepath</parameter-->
- <!--parameter name="httpGetProcessor" locked="false">org.wso2.carbon.transport.nhttp.api.NHttpGetProcessor</parameter-->
- <!--/transportReceiver-->
+ <parameter name="httpGetProcessor" locked="false">org.wso2.carbon.transport.nhttp.api.NHttpGetProcessor</parameter>
+ </transportReceiver>
<!-- the non blocking https transport based on HttpCore + SSL-NIO extensions -->
- <!--transportReceiver name="https" class="org.apache.synapse.transport.nhttp.HttpCoreNIOSSLListener">
+ <transportReceiver name="https" class="org.apache.synapse.transport.nhttp.HttpCoreNIOSSLListener">
<parameter name="port" locked="false">8243</parameter>
- <parameter name="non-blocking" locked="false">true</parameter-->
+ <parameter name="non-blocking" locked="false">true</parameter>
<!--parameter name="bind-address" locked="false">hostname or IP address</parameter-->
<!--parameter name="WSDLEPRPrefix" locked="false">https://apachehost:port/somepath</parameter-->
- <!--parameter name="httpGetProcessor" locked="false">org.wso2.carbon.transport.nhttp.api.NHttpGetProcessor</parameter-->
- <!--parameter name="keystore" locked="false">
+ <parameter name="httpGetProcessor" locked="false">org.wso2.carbon.transport.nhttp.api.NHttpGetProcessor</parameter>
+ <parameter name="keystore" locked="false">
<KeyStore>
<Location>repository/resources/security/wso2carbon.jks</Location>
<Type>JKS</Type>
@@ -273,22 +273,22 @@
<Type>JKS</Type>
<Password>wso2carbon</Password>
</TrustStore>
- </parameter-->
+ </parameter>
<!--<parameter name="SSLVerifyClient">require</parameter>
supports optional|require or defaults to none -->
- <!--/transportReceiver-->
+ </transportReceiver>
<!-- ================================================= -->
<!-- Transport Outs (Senders) -->
<!-- ================================================= -->
<!--Default trasnport will be passthrough if you need to change please add it here -->
- <transportSender name="http" class="org.apache.synapse.transport.passthru.PassThroughHttpSender">
+ <!--transportSender name="http" class="org.apache.synapse.transport.passthru.PassThroughHttpSender">
<parameter name="non-blocking" locked="false">true</parameter>
- <parameter name="warnOnHTTP500" locked="false">*</parameter>
+ <parameter name="warnOnHTTP500" locked="false">*</parameter-->
<!--parameter name="http.proxyHost" locked="false">localhost</parameter>
<parameter name="http.proxyPort" locked="false">3128</parameter>
<parameter name="http.nonProxyHosts" locked="false">localhost|moon|sun</parameter-->
- </transportSender>
+ <!--/transportSender>
<transportSender name="https" class="org.apache.synapse.transport.passthru.PassThroughHttpSSLSender">
<parameter name="non-blocking" locked="false">true</parameter>
<parameter name="keystore" locked="false">
@@ -306,11 +306,11 @@
<Password>wso2carbon</Password>
</TrustStore>
</parameter>
- <parameter name="HostnameVerifier">AllowAll</parameter>
+ <parameter name="HostnameVerifier">AllowAll</parameter-->
<!--supports Strict|AllowAll|DefaultAndLocalhost or the default if none specified -->
- </transportSender>
+ <!--/transportSender-->
<!-- Uncomment for non-blocking http transport based on HttpCore + NIO extensions -->
- <!--transportSender name="http" class="org.apache.synapse.transport.nhttp.HttpCoreNIOSender">
+ <transportSender name="http" class="org.apache.synapse.transport.nhttp.HttpCoreNIOSender">
<parameter name="non-blocking" locked="false">true</parameter>
</transportSender>
<transportSender name="https" class="org.apache.synapse.transport.nhttp.HttpCoreNIOSSLSender">
@@ -332,7 +332,7 @@
</parameter>
<parameter name="HostnameVerifier">AllowAll</parameter-->
<!--supports Strict|AllowAll|DefaultAndLocalhost or the default if none specified -->
- <!--/transportSender-->
+ </transportSender>
<transportSender name="local" class="org.apache.axis2.transport.local.LocalTransportSender"/>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/0fc81578/tools/cartridge_create/init_scripts/tomcat/stratos-init.sh
----------------------------------------------------------------------
diff --git a/tools/cartridge_create/init_scripts/tomcat/stratos-init.sh b/tools/cartridge_create/init_scripts/tomcat/stratos-init.sh
index 129a150..0495b7b 100644
--- a/tools/cartridge_create/init_scripts/tomcat/stratos-init.sh
+++ b/tools/cartridge_create/init_scripts/tomcat/stratos-init.sh
@@ -19,22 +19,24 @@
# under the License.
# ----------------------------------------------------------------------------
-export LOG=/var/log/wso2-openstack.log
-instance_path=/var/lib/cloud/instance
+
+
+export LOG=/var/log/stratos-init.log
+instance_path=/opt
PUBLIC_IP=""
KEY=`uuidgen`
CRON_DURATION=1
RETRY_COUNT=30
-SLEEP_DURATION=30
+SLEEP_DURATION=3
if [ ! -d ${instance_path}/payload ]; then
echo "creating payload dir ... " >> $LOG
mkdir ${instance_path}/payload
echo "payload dir created ... " >> $LOG
- cp ${instance_path}/user-data.txt ${instance_path}/payload/user-data.zip
+ wget http://169.254.169.254/latest/user-data -O ${instance_path}/payload/payload.zip
echo "payload copied ... " >> $LOG
- unzip -d ${instance_path}/payload ${instance_path}/payload/user-data.zip
+ unzip -d ${instance_path}/payload ${instance_path}/payload/payload.zip
echo "unzippeddd..." >> $LOG
for i in `/usr/bin/ruby /opt/get-launch-params.rb`
@@ -43,11 +45,6 @@ if [ ! -d ${instance_path}/payload ]; then
echo "export" ${i} >> /home/ubuntu/.bashrc
done
source /home/ubuntu/.bashrc
- # Write a cronjob to execute wso2-openstack-init.sh periodically until public ip is assigned
- #crontab -l > ./mycron
- #echo "*/${CRON_DURATION} * * * * /opt/wso2-openstack-init.sh > /var/log/wso2-openstack-init.log" >> ./mycron
- #crontab ./mycron
- #rm ./mycron
fi
@@ -59,7 +56,7 @@ wget http://169.254.169.254/latest/meta-data/public-ipv4
files="`cat public-ipv4`"
if [[ -z ${files} ]]; then
echo "getting public ip" >> $LOG
- for i in {1..$RETRY_COUNT}
+ for i in {1..30}
do
rm -f ./public-ipv4
wget http://169.254.169.254/latest/meta-data/public-ipv4
@@ -69,7 +66,6 @@ if [[ -z ${files} ]]; then
sleep $SLEEP_DURATION
else
echo "Public ip assigned" >> $LOG
- #crontab -r
break
fi
done
@@ -86,7 +82,6 @@ if [[ -z ${files} ]]; then
else
PUBLIC_IP="$files"
- #crontab -r
fi
@@ -95,14 +90,19 @@ do
export ${i}
done
-#PORTS=HTTP:8280:80|HTTPS:8243:443
-#MYSQL_HOST
-#MYSQL_USER
-#MYSQL_PASSWORD
-echo "Logging sys variables .. PUBLIC_IP:$PUBLIC_IP, HOST_NAME:$HOST_NAME, KEY:$KEY, PORTS=$PORTS , BAM:$BAM_IP, GITREPO:${GIT_REPO}" >> $LOG
+echo "Restarting apache..." >> $LOG
+
+/etc/init.d/apache2 restart
+
+echo "Apache restarted..." >> $LOG
+
+
+echo "Logging sys variables .. PUBLIC_IP:${PUBLIC_IP}, HOST_NAME:${HOST_NAME}, KEY:${KEY}, PORTS=${PORTS}, BAM:${BAM_IP}, GITREPO:${GIT_REPO}" >> $LOG
-echo "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:agen=\"http://agent.cartridge.carbon.wso2.org\">
+mkdir -p /etc/agent/conf
+
+echo "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:agen=\"http://service.agent.cartridge.stratos.apache.org\">
<soapenv:Header/>
<soapenv:Body>
<agen:register>
@@ -115,7 +115,7 @@ echo "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope
<maxRequestsPerSecond>${MAX_REQUESTS_PER_SEC}</maxRequestsPerSecond>
<minInstanceCount>${MIN}</minInstanceCount> " > /etc/agent/conf/request.xml
-IFS='|' read -ra PT <<< "$PORTS"
+IFS='|' read -ra PT <<< "${PORTS}"
for i in "${PT[@]}"; do
IFS=':' read -ra PP <<< "$i"
echo " <portMappings>
@@ -137,32 +137,138 @@ echo " <remoteHost>${PUBLIC_IP}</remoteHost>
</soapenv:Envelope>
" >> /etc/agent/conf/request.xml
+echo "Creating repoinfo request " >> $LOG
+echo "TENANT_ID and SERVICE ${TENANT_ID} and ${SERVICE} " >> $LOG
+set -- "${HOST_NAME}"
+IFS="."; declare -a Array=($*)
+ALIAS="${Array[0]}"
+echo "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://org.apache.axis2/xsd\">
+ <soapenv:Header/>
+ <soapenv:Body>
+ <xsd:getRepositoryCredentials>
+ <xsd:tenantId>${TENANT_ID}</xsd:tenantId>
+ <xsd:cartridgeType>${SERVICE}</xsd:cartridgeType>
+ <xsd:alias>${ALIAS}</xsd:alias>
+ </xsd:getRepositoryCredentials>
+ </soapenv:Body>
+</soapenv:Envelope>" > /opt/repoinforequest.xml
+
+echo "Repoinfo request created " >> $LOG
+
echo "Private Key....Copying to .ssh " >> $LOG
cp ${instance_path}/payload/id_rsa /root/.ssh/id_rsa
chmod 0600 /root/.ssh/id_rsa
echo "StrictHostKeyChecking no" >> /root/.ssh/config
-echo "Sending register request to Cartridge agent service" >> $LOG
-curl -X POST -H "Content-Type: text/xml" -d @/etc/agent/conf/request.xml --silent --output /dev/null "$CARTRIDGE_AGENT_EPR"
+
+
+#echo "Getting repo username password from repoInfoService" >> $LOG
+#curl -X POST -H "Content-Type: text/xml" -d @/etc/agent/conf/request.xml --silent --output /dev/null "${CARTRIDGE_AGENT_EPR}"
echo "Git repo sync" >> $LOG
# If repo is available do a git pull, else clone
+
echo "#!/bin/bash
-if [ -d "$APP_PATH/.git" ]; then
- cd ${APP_PATH}/
- sudo git pull
+if [ -d \"${APP_PATH}/.git\" ]; then
+ cd ${APP_PATH}
+
+ curl -X POST -H \"Content-Type: text/xml\" -H \"SOAPAction: urn:getRepositoryCredentials\" -d @/opt/repoinforequest.xml --silent \"${REPO_INFO_EPR}\" --insecure > /tmp/git.xml
+ sed '1,5d' /tmp/git.xml > /tmp/git1.xml
+ sed '2d' /tmp/git1.xml > /tmp/git.xml
+ username=\`xml_grep 'ax29:userName' /tmp/git.xml --text_only\`
+ password=\`xml_grep 'ax29:password' /tmp/git.xml --text_only\`
+ repo=\`xml_grep 'ax29:url' /tmp/git.xml --text_only\`
+ rm /tmp/git1.xml
+ rm /tmp/git.xml
+ url=\`echo \$repo |sed 's/http.*\/\///g' |sed 's/\:.*//g' |sed 's/\/.*//g'\`
+ echo \"machine \${url} login \${username} password \${password}\" > ~/.netrc
+ sudo echo \"machine \${url} login \${username} password \${password}\" > /root/.netrc
+ chmod 600 ~/.netrc
+ sudo chmod 600 /root/.netrc
+ git config --global --bool --add http.sslVerify false
+ sudo git pull
+ rm ~/.netrc
+ sudo rm /root/.netrc
+
else
+ curl -X POST -H \"Content-Type: text/xml\" -H \"SOAPAction: urn:getRepositoryCredentials\" -d @/opt/repoinforequest.xml --silent \"${REPO_INFO_EPR}\" --insecure > /tmp/git.xml
+ sed '1,5d' /tmp/git.xml > /tmp/git1.xml
+ sed '2d' /tmp/git1.xml > /tmp/git.xml
+ username=\`xml_grep 'ax29:userName' /tmp/git.xml --text_only\`
+ password=\`xml_grep 'ax29:password' /tmp/git.xml --text_only\`
+ repo=\`xml_grep 'ax29:url' /tmp/git.xml --text_only\`
+ rm /tmp/git1.xml
+ rm /tmp/git.xml
+ url=\`echo \$repo |sed 's/http.*\/\///g' |sed 's/\:.*//g' |sed 's/\/.*//g'\`
+ echo \"machine \${url} login \${username} password \${password}\" > ~/.netrc
+ sudo echo \"machine \${url} login \${username} password \${password}\" > /root/.netrc
+ chmod 600 ~/.netrc
+ sudo chmod 600 /root/.netrc
+ git config --global --bool --add http.sslVerify false
cd ${APP_PATH}
- mv ROOT ../
- sudo git clone ${GIT_REPO} ${APP_PATH}
- mv ../ROOT .
+ sudo mv ROOT ../
+ sudo git clone \${repo} ${APP_PATH}
+ sudo mv ../ROOT .
+ rm ~/.netrc
+ sudo rm /root/.netrc
+
+
fi" > /opt/git.sh
echo "File created.." >> $LOG
chmod 755 /opt/git.sh
+
+
+
+while true
+do
+var=`nc -z localhost 8080; echo $?`;
+if [ $var -eq 0 ]
+ then
+ echo "port 8080 is available" >> $LOG
+ break
+ else
+ echo "port 8080 is not available" >> $LOG
+ fi
+ sleep 1
+done
+
+
+
+
+
+echo "Sending register request to Cartridge agent service" >> $LOG
+
+curl -X POST -H "Content-Type: text/xml" -H "SOAPAction: urn:register" -d @/etc/agent/conf/request.xml -k --silent --output /dev/null "${CARTRIDGE_AGENT_EPR}"
+
+echo "Registered cartridge..." >> $LOG
+
echo "running git clone........" >> $LOG
-/opt/git.sh
+su - ubuntu /opt/git.sh
+
+
+echo "setting up logging conf" >> $LOG
+
+
+echo "host: ${BAM_IP}
+thriftPort: ${BAM_PORT}
+
+#cartridge configs
+cartridgeAlias: ${CARTRIDGE_ALIAS}
+tenantName: ${HOST_NAME}
+tenantId: ${TENANT_ID}
+localIP: ${PUBLIC_IP}" > /opt/cartridge_data_publisher_1.0.2/conf/data_publisher.conf
+
+
+
+echo "started loggin ........."
+cd /opt/cartridge_data_publisher_1.0.2/dist/Debug/GNU-Linux-x86/
+nohup ./cartridge_data_publisher_1.0.2 /var/lib/tomcat7/logs/catalina.out >> /var/log/stratos-data-publisher.log &
+
+
+
+
# ========================== // End of script ===========================================================