github.com/polarismesh/polaris@v1.17.8/release/tool/include (about)

     1  # Tencent is pleased to support the open source community by making Polaris available.
     2  #
     3  # Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
     4  #
     5  # Licensed under the BSD 3-Clause License (the "License");
     6  # you may not use this file except in compliance with the License.
     7  # You may obtain a copy of the License at
     8  #
     9  # https://opensource.org/licenses/BSD-3-Clause
    10  #
    11  # Unless required by applicable law or agreed to in writing, software distributed
    12  # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
    13  # CONDITIONS OF ANY KIND, either express or implied. See the License for the
    14  # specific language governing permissions and limitations under the License.
    15  
    16  server_name="polaris-server"
    17  cmdline="./polaris-server start"
    18  
    19  function log_date() {
    20      echo $(date "+%Y-%m-%dT%H:%M:%S")
    21  }
    22  
    23  function log_error() {
    24      echo -e "\033[31m\033[01m$(log_date)\terror\t$1 \033[0m"
    25  }
    26  
    27  function log_info() {
    28      echo -e "\033[32m\033[01m$(log_date)\tinfo\t$1 \033[0m"
    29  }
    30  
    31  function del_file() {
    32      log_info "del file for $server_name"
    33  
    34      rm -rf ./log
    35      rm -rf ./statis
    36      rm -rf ./discover-statis
    37  }
    38  
    39  function start() {
    40      log_info "start $server_name"
    41  
    42      if [ ! -d "./log" ]; then
    43          mkdir ./log
    44      fi
    45  
    46      if [ ! -d "./statis" ]; then
    47          mkdir ./statis
    48      fi
    49      set +e
    50      ulimit -n 409600
    51      set -e
    52      nohup $cmdline >>./log/stdout 2>&1 &
    53  }
    54  
    55  function stop() {
    56      pids=$(ps -ef | grep -w "$cmdline" | grep -v "grep" | awk '{print $2}')
    57      array=($pids)
    58      for pid in ${array[@]}; do
    59          log_info "stop $server_name: pid=$pid"
    60  
    61          kill -15 $pid
    62      done
    63  }