1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- #!/usr/bin/env bash
- set +u
- set -e
- base_dir=$(
- cd "$(dirname "$0")"
- pwd
- )
- cd $base_dir
- if [[ $1 != "no_logo" ]]; then
- cat << 'LOGO'
- ###############################################################
- 关闭服务脚本
- ###############################################################
- LOGO
- else
- shift 1
- fi
- # extra function
- ## func of log
- function log_warn() {
- local date=$(date "+%Y-%m-%d-%H:%M:%S")
- local para=$1
- echo "[WARN] $date $1" | tee -a "./log/stop_log"
- }
- function log_info() {
- local date=$(date "+%Y-%m-%d-%H:%M:%S")
- local para=$1
- echo "[INFO] $date $1" | tee -a "./log/stop_log"
- }
- function log_err() {
- local date=$(date "+%Y-%m-%d-%H:%M:%S")
- local para=$1
- echo "[ERROR] $date $1" | tee -a "./log/stop_log"
- }
- function stop_process() {
- ID=$(ps -auxc | grep "$1" | grep -v "$0" | grep -v "grep" | awk '{print $2}')
- if [[ "$ID" ]]; then
- log_info "$1 运行中,准备关闭"
- for id in $ID; do
- kill -15 "$id"
- echo "stop $1 process:(PID=${id})"
- done
- echo "---------------"
- fi
- }
- if [[ -z $1 ]]; then
- stop_process "minio-into-stck"
- log_info "服务停止脚本运行完成"
- fi
|