源战役
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
1.9 KiB

  1. #!/usr/bin/env bash
  2. # huangyongxing@yeah.net
  3. # 模拟客户端编译运行管理
  4. BASE_DIR=$(cd $(dirname $0); pwd)
  5. cd ${BASE_DIR}/
  6. APP_PATH=$(pwd)/config
  7. SVR_PATH=$(dirname $(dirname ${BASE_DIR}))
  8. BEAM_PATH=${SVR_PATH}/ebin
  9. ERL_OPTION_NO_SMP="+P 204800 +K true +A 100 +spp true -smp disable -hidden +sbwt none"
  10. ERL_OPTION_SMP="+P 204800 +K true +A 100 +spp true -smp enable -hidden +sbwt none"
  11. # ERL=/opt/erlang-otp-19.3/bin/erl
  12. # ERL=/opt/erlang-otp-23.2.6/bin/erl
  13. ERL=erl
  14. function fun_start() {
  15. # 切换到BEAM_PATH,以确保logs目录的相对位置正确
  16. cd ${BEAM_PATH}
  17. local nodeName=imitation$RANDOM@127.0.0.1
  18. local cookie=test
  19. "${ERL}" ${ERL_OPTION_SMP} -name ${nodeName} -setcookie ${cookie} -boot start_sasl -sasl sasl_error_logger false -sasl errlog_type error -pa ${APP_PATH} -pa ${SVR_PATH}/config -s cli_simu start
  20. }
  21. function fun_make() {
  22. cd ${SVR_PATH}
  23. # "${ERL}" -noinput -smp enable -make
  24. # local makeOptions='[{i,"include"},{outdir,"ebin"}]'
  25. # "${ERL}" -noinput -smp enable -eval "Files = filelib:wildcard(\"test/cli_simu/src/*.erl\"), make:files(Files, ${makeOptions})" -s c q
  26. "${ERL}" -noinput -smp enable -eval "Files = filelib:wildcard(\"test/cli_simu/src/**/*.erl\"), make:files(Files)" -s c q
  27. }
  28. function usage() {
  29. cat <<EOF
  30. --------------------------------------------------------------------------
  31. m 编译
  32. s 开启模拟客户端管理器
  33. q 退出
  34. (10分钟未输入指令将自动退出)
  35. --------------------------------------------------------------------------
  36. EOF
  37. }
  38. function main() {
  39. local input
  40. usage
  41. while read -t 600 input
  42. do
  43. cd ${APP_PATH}
  44. case "$input" in
  45. "m")
  46. fun_make
  47. ;;
  48. "s")
  49. fun_start
  50. ;;
  51. "q")
  52. break;;
  53. *)
  54. continue;;
  55. esac
  56. usage
  57. done
  58. }
  59. main