Commit b8cf76e8 authored by wentao.suo's avatar wentao.suo

edit rabbitmq sh

parent 507800f0
#!/bin/bash #!/bin/bash
if [[ -e /.firstrun ]]; then if [[ -e /.firstrun ]]; then
/scripts/init_script.sh /scripts/init_script.sh
fi fi
...@@ -11,79 +12,68 @@ echo "Starting RabbitMQ..." ...@@ -11,79 +12,68 @@ echo "Starting RabbitMQ..."
nohup /usr/sbin/rabbitmq-server > /tmp/rabbitmq.out & nohup /usr/sbin/rabbitmq-server > /tmp/rabbitmq.out &
export NAMESPACE=`cat /var/run/secrets/kubernetes.io/serviceaccount/namespace`
function wait(){
count=1 count=1
until [[ $count -eq 300 ]] || [[ $is_running -eq 1 ]] until [[ $count -eq 300 ]] || [[ $is_running -eq 1 ]]
do do
let count+=1 let count+=1
echo "count is $count" echo "count is $count"
curl -X GET -H "Authorization: Basic cWE6cWF0ZXN0" "http://localhost:15672/api/definitions" curl -X GET -H "Authorization: Basic cWE6cWF0ZXN0" "http://localhost:15672/api/definitions"
if [ $? -eq 0 ] if [ $? -eq 0 ]
then then
echo "rabbitmq is running rabbitmq-plugins enable rabbitmq_delayed_message_exchange" echo "rabbitmq is running rabbitmq-plugins enable rabbitmq_delayed_message_exchange"
rabbitmq-plugins enable rabbitmq_delayed_message_exchange rabbitmq-plugins enable rabbitmq_delayed_message_exchange
tail -f /tmp/rabbitmq.out curl --request POST \
else --url http://192.168.6.13/api/etcd/set_env_job_status \
echo "rabbitmq is not running" --header 'Content-Type: application/json' \
sleep 1 --data "{\"namespace\": \"$NAMESPACE\",\"job_name\": \"rabbitmq_sync\",\"status\": \"pending\"}"
fi
done count_wait=1
} is_running=0
until [[ $count_wait -eq 300 ]] || [[ $is_running -eq 1 ]]
do
function sync_config(){ let count_wait+=1
count=1 echo "count_wait is count_wait"
is_running=0 curl -X GET -H "Authorization: Basic cWE6cWF0ZXN0" "http://localhost:15672/api/definitions"
export NAMESPACE=`cat /var/run/secrets/kubernetes.io/serviceaccount/namespace`
curl --request POST \
--url http://192.168.6.13/api/etcd/set_env_job_status \
--header 'Content-Type: application/json' \
--data "{\"namespace\": \"$NAMESPACE\",\"job_name\": \"rabbitmq_sync\",\"status\": \"pending\"}"
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 ] if [ $? -eq 0 ]
then then
echo "rabbitmq is running" echo "rabbitmq is running"
is_running=1 is_running=1
else else
echo "rabbitmq is not running" echo "rabbitmq is not running"
sleep 1 sleep 1
fi fi
done done
if [[ $is_running -eq 1 ]] if [[ $is_running -eq 1 ]]
then then
echo "rabbitmq is running!!! start execution sync job" echo "rabbitmq is running!!! start execution sync job"
echo "init rabbit with eos server" echo "init rabbit with eos server"
# echo "get definitions from 172.16.1.231" # echo "get definitions from 172.16.1.231"
# response=$(curl -X GET -H "Authorization: Basic cmFiYml0X2FkbWluOmFiYzEyMzQ=" "http://172.16.1.231:15672/api/definitions") # 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" # curl -X POST -H "Content-Type: application/json" -H "Authorization: Basic cWE6cWF0ZXN0" -d $response "http://rabbitmq:15672/api/definitions"
response=$(curl -X POST -H "Content-Type: application/json" -d "{\"namespace\":\"$NAMESPACE\"}" "http://eos.quantgroups.com/api/etcd/init_env_rabbitmq_config") response=$(curl -X POST -H "Content-Type: application/json" -d "{\"namespace\":\"$NAMESPACE\"}" "http://192.168.6.13/api/etcd/init_env_rabbitmq_config")
echo $response echo $response
else else
echo "rabbitmq is not running!!! Do not execution sync job" echo "rabbitmq is not running!!! Do not execution sync job"
fi fi
curl --request POST \ curl --request POST \
--url http://192.168.6.13/api/etcd/set_env_job_status \ --url http://192.168.6.13/api/etcd/set_env_job_status \
--header 'Content-Type: application/json' \ --header 'Content-Type: application/json' \
--data "{\"namespace\": \"$NAMESPACE\",\"job_name\": \"rabbitmq_sync\",\"status\": \"done\"}" --data "{\"namespace\": \"$NAMESPACE\",\"job_name\": \"rabbitmq_sync\",\"status\": \"done\"}"
} tail -f /tmp/rabbitmq.out
else
echo "rabbitmq is not running"
sleep 1
fi
done
wait
sync_config
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