ctrl.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/bin/sh
  2. DOCKER_DIR=/open-falcon
  3. of_bin=$DOCKER_DIR/open-falcon
  4. DOCKER_HOST_IP=$(route -n | awk '/UG[ \t]/{print $2}')
  5. # Search $1 and replace with $2 or $3(defualt)
  6. replace() {
  7. replacement=$2
  8. if [ -z "$replacement" ]; then
  9. replacement=$3
  10. fi
  11. find $DOCKER_DIR/*/config/*.json -type f -exec sed -i "s/$1/$replacement/g" {} \;
  12. }
  13. replace "%%MYSQL%%" "$MYSQL_PORT" "$DOCKER_HOST_IP:3306"
  14. replace "%%REDIS%%" "$REDIS_PORT" "$DOCKER_HOST_IP:6379"
  15. replace "%%AGGREGATOR_HTTP%%" "$AGGREGATOR_HTTP" "0.0.0.0:6055"
  16. replace "%%GRAPH_HTTP%%" "$GRAPH_HTTP" "0.0.0.0:6071"
  17. replace "%%GRAPH_RPC%%" "$GRAPH_RPC" "0.0.0.0:6070"
  18. replace "%%HBS_HTTP%%" "$HBS_HTTP" "0.0.0.0:6031"
  19. replace "%%HBS_RPC%%" "$HBS_RPC" "0.0.0.0:6030"
  20. replace "%%JUDGE_HTTP%%" "$JUDGE_HTTP" "0.0.0.0:6081"
  21. replace "%%JUDGE_RPC%%" "$JUDGE_RPC" "0.0.0.0:6080"
  22. replace "%%NODATA_HTTP%%" "$NODATA_HTTP" "0.0.0.0:6090"
  23. replace "%%TRANSFER_HTTP%%" "$TRANSFER_HTTP" "0.0.0.0:6060"
  24. replace "%%TRANSFER_RPC%%" "$TRANSFER_RPC" "0.0.0.0:8433"
  25. replace "%%PLUS_API_HTTP%%" "$PLUS_API_HTTP" "0.0.0.0:8080"
  26. replace "%%AGENT_HOSTNAME%%" "$AGENT_HOSTNAME" ""
  27. #use absolute path of metric_list_file in docker
  28. TAB=$'\t'; sed -i "s|.*metric_list_file.*|${TAB}\"metric_list_file\": \"$DOCKER_DIR/api/data/metric\",|g" $DOCKER_DIR/api/config/*.json;
  29. action=$1
  30. module_name=$2
  31. case $action in
  32. run)
  33. $DOCKER_DIR/"$module_name"/bin/falcon-"$module_name" -c /open-falcon/"$module_name"/config/cfg.json
  34. ;;
  35. *)
  36. supervisorctl $*
  37. ;;
  38. esac