run.sh 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #!/usr/bin/env bash
  2. set +u
  3. set -e
  4. # set -x
  5. base_dir=$(
  6. cd "$(dirname "$0")"
  7. pwd
  8. )
  9. cd $base_dir
  10. echo $base_dir
  11. # ./auto_del_log.sh
  12. function log_warn() {
  13. local date=$(date "+%Y-%m-%d-%H:%M:%S")
  14. local para=$1
  15. echo "[WARN] $date $1" | tee -a "./log/run_log"
  16. }
  17. function log_info() {
  18. local date=$(date "+%Y-%m-%d-%H:%M:%S")
  19. local para=$1
  20. echo "[INFO] $date $1" | tee -a "./log/run_log"
  21. }
  22. function log_err() {
  23. local date=$(date "+%Y-%m-%d-%H:%M:%S")
  24. local para=$1
  25. echo "[ERROR] $date $1" | tee -a "./log/run_log"
  26. }
  27. ulimit -n 100000
  28. if [[ $1 != "no_logo" ]]; then
  29. cat << 'LOGO'
  30. ###############################################################
  31. 配置文件:
  32. ./config/
  33. ###############################################################
  34. LOGO
  35. else
  36. shift 1
  37. fi
  38. # parameter set
  39. log_path="./log/minio-into-stck/"
  40. # extra function
  41. if [[ ! -d "$base_dir/log" ]]; then
  42. echo "log文件夹不存在,创建log文件夹" && mkdir "./log"
  43. fi
  44. # preparation check
  45. if [[ ! -d "$base_dir/lib" ]]; then
  46. log_err "缺少lib文件夹,请查证后重新运行此脚本" && exit 1
  47. fi
  48. if [[ ! -f "$base_dir/minio-into-stck" ]]; then
  49. log_err "文件夹中缺少minio-into-stck(主程序),无法运行" && exit 1
  50. fi
  51. if [[ ! -x "$base_dir/minio-into-stck" ]]; then
  52. log_err "minio-into-stck无可执行权限,无法运行。请使用chmod" && exit 1
  53. fi
  54. if [[ ! -f "$base_dir/license/license_key.json" ]]; then
  55. log_warn "您可能未开始、或未完成授权过程.现在生成key,请之后完成授权过程再启动此脚本"
  56. # exit 1
  57. fi
  58. ###################################################################################################
  59. if ps -auxc | grep "minio-into-stck" | grep -v grep > /dev/null; then
  60. log_info "minio-into-stck已在运行"
  61. else
  62. if [[ ! -d $log_path ]]; then
  63. mkdir "$log_path"
  64. fi
  65. log_file="minio-into-stck_$(date "+%Y-%m-%d-%H:%M:%S").log"
  66. ./minio-into-stck server --config-file=$base_dir/config/config.xml &> "${log_path}${log_file}" &
  67. ./status.sh
  68. fi