1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- #!/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
- # parameter set
- log_path="./log/watch-daemon/"
- # extra function
- if [[ ! -d "$base_dir/log" ]]; then
- echo "log文件夹不存在,创建log文件夹" && mkdir "./log"
- fi
- # preparation check
- if [[ ! -f "$base_dir/watch-daemon" ]]; then
- log_err "文件夹中缺少watch-daemon(主程序),无法运行" && exit 1
- fi
- if [[ ! -x "$base_dir/watch-daemon" ]]; then
- log_err "watch-daemon无可执行权限,无法运行。请使用chmod" && exit 1
- fi
- ###################################################################################################
- if ps -auxc | grep "watch-daemon" | grep -v grep > /dev/null; then
- log_info "watch-daemon已在运行"
- else
- if [[ ! -d $log_path ]]; then
- mkdir "$log_path"
- fi
- log_file="watch-daemon_$(date "+%Y-%m-%d-%H:%M:%S").log"
- ./watch-daemon --config-file=$base_dir/config/config.xml &> "${log_path}${log_file}" &
- fi
|