Commit c9db655b authored by kalvin's avatar kalvin

修改目录结构

parent 9c50d64f
FROM 192.168.4.36/baseimg/python:latest
USER root
WORKDIR /home/quant_group
COPY checker.py .
RUN chmod +x ./docker-entrypoint.sh
CMD ["python", "-c", "checker.py"]
\ No newline at end of file
import requests
import time
import json
def check():
url = "http://192.168.29.116:9001/api/etcd/get_env_job_status"
querystring = {"namespace":"0zhangbo"}
headers = {}
response = requests.request("GET", url, headers=headers, params=querystring)
return json.loads(response.text)
count = 0
all_job_is_done = False
while True:
res = check()
for instance in res["details"]["instances"]:
db_sync = instance["db_sync"]
rabbitmq_sync = instance["rabbitmq_sync"]
if db_sync == "done" and rabbitmq_sync == "done":
print "All of the sync job is done!"
all_job_is_done = True
else:
print "db_sync is:" + db_sync
print "rabbitmq_sync is:" + rabbitmq_sync
time.sleep(2)
if count == 120 or all_job_is_done:
break
\ No newline at end of file
FROM 192.168.4.36/baseimg/mysql:latest
USER root
WORKDIR /home/quant_group
COPY docker-entrypoint.sh .
RUN chmod +x ./docker-entrypoint.sh
CMD ["./docker-entrypoint.sh"]
\ No newline at end of file
#!/bin/bash
USER='qa'
PASSWORD='qatest'
count=1
db_is_running=0
until [[ $count -eq 300 ]] || [[ $db_is_running -eq 1 ]]
do
let count+=1
echo "count is $count"
mysqladmin -h db -u$USER -p$PASSWORD processlist
if [ $? -eq 0 ]
then
echo "db is running"
db_is_running=1
else
echo "db is not running"
sleep 1
fi
done
if [[ $db_is_running -eq 1 ]]
then
echo "db is running!!! start execution replace job"
export NAMESPACE=`cat /var/run/secrets/kubernetes.io/serviceaccount/namespace`
curl --request POST \
--url http://192.168.29.116:9001/api/etcd/set_env_job_status \
--header 'Content-Type: application/json' \
--data '{\n "namespace": "' + NAMESPACE + '",\n "job_name": "db_sync",\n "status": "running"\n}'
echo "start replace db domain"
DB_FILE=dump.sql
HOST=$DB_SERVICE_HOST
PORT='3306'
HTTPS='true'
echo "HOST=$HOST
PORT=$PORT
USER=$USER
PASSWORD=$PASSWORD
HTTPS=$HTTPS
NAMESPACE=$NAMESPACE"
EXCLUDED_TABLES=(
clotho.JOB_EXECUTION_LOG
clotho.JOB_STATUS_TRACE_LOG
notify.JOB_EXECUTION_LOG
notify.JOB_STATUS_TRACE_LOG
xyqb.JOB_EXECUTION_LOG
xyqb.JOB_STATUS_TRACE_LOG
xyqb.t_phonenum
mall.jd_address
mall.jd_brand
mall.jd_product_sku_image
mall.jd_property
mall.jd_sku
mall.jd_sku_detail_image
mall.jd_sku_specs
mall.spu_image
mall.sale_product_detail
mall.product_nature_value_bak
mall.product_sku
mall.product_sku_image
mall.product_specification
mall.product_spu
)
IGNORED_TABLES_STRING=''
for TABLE in "${EXCLUDED_TABLES[@]}"
do :
IGNORED_TABLES_STRING+=" --ignore-table=${TABLE}"
done
echo "mysqldump --host=${HOST} --port=${PORT} --user=${USER} --password=${PASSWORD} --all-databases --no-create-info ${IGNORED_TABLES_STRING} > ${DB_FILE}"
mysqldump --host=${HOST} --port=${PORT} --user=${USER} --password=${PASSWORD} --all-databases ${IGNORED_TABLES_STRING} >> ${DB_FILE}
echo "sed file"
if [[ $HTTPS = true ]];then
sed -i "s#\.xyqb\.com#-${NAMESPACE}\.q-gp\.com#g; s#\.quantgroup\.cn#-${NAMESPACE}\.q-gp\.com#g; s#-(\w*)\.q-gp\.com#-${NAMESPACE}\.q-gp\.com#g" ${DB_FILE}
else
sed -i "s#\.xyqb\.com#-${NAMESPACE}\.q-gp\.com#g; s#\.quantgroup\.cn#-${NAMESPACE}\.q-gp\.com#g; s#-(\w*)\.q-gp\.com#-${NAMESPACE}\.q-gp\.com#g; s#\https#http#g" ${DB_FILE}
fi
echo "mysql dump file"
mysql --host=${HOST} --port=${PORT} --user=${USER} --password=${PASSWORD} < ${DB_FILE}
else
echo "db is not running!!! Do not execution replace job"
fi
#回调更新任务状态
count=1
db_is_running=0
until [[ $count -eq 60 ]] || [[ $db_is_running -eq 1 ]]
do
let count+=1
echo "count is $count"
mysqladmin -h db -u$USER -p$PASSWORD processlist
if [ $? -eq 0 ]
then
db_is_running=1
curl --request POST \
--url http://192.168.29.116:9001/api/etcd/set_env_job_status \
--header 'Content-Type: application/json' \
--data '{\n "namespace": "' + NAMESPACE + '",\n "job_name": "db_sync",\n "status": "done"\n}'
else
echo "db is not running"
sleep 1
fi
done
FROM 192.168.4.36/baseimg/centos:12251535
USER root
WORKDIR /home/quant_group
COPY docker-entrypoint.sh .
RUN chmod +x ./docker-entrypoint.sh
CMD ["./docker-entrypoint.sh"]
\ No newline at end of file
#!/bin/sh
count=1
is_running=0
until [[ $count -eq 300 ]] || [[ $is_running -eq 1 ]]
do
let count+=1
echo "count is $count"
curl -X GET -H "Authorization: Basic cWE6cWF0ZXN0" "http://rabbitmq:15672/api/definitions"
if [ $? -eq 0 ]
then
echo "rabbitmq is running"
is_running=1
else
echo "rabbitmq is not running"
sleep 1
fi
done
if [[ $is_running -eq 1 ]]
then
echo "rabbitmq is running!!! start execution sync job"
echo "get definitions from 172.16.1.231"
response=$(curl -X GET -H "Authorization: Basic cmFiYml0X2FkbWluOmFiYzEyMzQ=" "http://172.16.1.231:15672/api/definitions")
curl -X POST -H "Content-Type: application/json" -H "Authorization: Basic cWE6cWF0ZXN0" -d $response "http://rabbitmq:15672/api/definitions"
else
echo "rabbitmq is not running!!! Do not execution sync job"
fi
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment