12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- #!/usr/bin/env bash
- set +u
- set -e
- # set -x
- base_dir=$(
- cd "$(dirname "$0")"
- pwd
- )
- cd $base_dir
- echo $base_dir
- # ./auto_del_log.sh
- function log_warn() {
- local date=$(date "+%Y-%m-%d-%H:%M:%S")
- local para=$1
- echo "[WARN] $date $1" | tee -a "./log/run_log"
- }
- function log_info() {
- local date=$(date "+%Y-%m-%d-%H:%M:%S")
- local para=$1
- echo "[INFO] $date $1" | tee -a "./log/run_log"
- }
- function log_err() {
- local date=$(date "+%Y-%m-%d-%H:%M:%S")
- local para=$1
- echo "[ERROR] $date $1" | tee -a "./log/run_log"
- }
- ulimit -n 100000
- if [[ $1 != "no_logo" ]]; then
- cat << 'LOGO'
- ###############################################################
- 配置文件:
- ./config/
- ###############################################################
- LOGO
- else
- shift 1
- fi
- BINARY_NAME="nsq-server"
- # parameter set
- log_path="./log/nsq-server/"
- # extra function
- if [[ ! -d "$base_dir/log" ]]; then
- echo "log文件夹不存在,创建log文件夹" && mkdir "./log"
- fi
- ###################################################################################################
- if pgrep -x "$BINARY_NAME"; then
- log_info "nsq-server已在运行"
- else
- if [[ ! -d $log_path ]]; then
- mkdir "$log_path"
- fi
- log_file="nsq-server_$(date "+%Y-%m-%d-%H:%M:%S").log"
- # ----- Start run -----
- echo "正在启动 nsq-server..."
- ./launcher.sh &> "${log_path}${log_file}"
- # ----- End run -----
- fi
|