1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- #!/usr/bin/env bash
- set +u
- set -e
- # set -x
- # base_dir=$(
- # cd "$(dirname "$0")"
- # pwd
- # )
- # cd $base_dir
- ROOT=$(cd `dirname $0`/../; pwd)
- app_name="CloudflareServer"
- app_path="${ROOT}/lib/"
- log_path="${ROOT}/logs/${app_name}/"
- # ./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"
- }
- if ps -auxw | grep "${app_name}" | grep -v grep > /dev/null; then
- log_info "${app_name} 已在运行"
- elif [[ ! -f "${app_path}${app_name}" ]]; then
- log_info "未找到 ${app_name} , 跳过"
- else
- if [[ ! -d ${log_path} ]]; then
- mkdir -p "${log_path}"
- fi
- log_file="${app_name}_$(date "+%Y-%m-%d-%H:%M:%S").log"
- ${app_path}${app_name} &>> "${log_path}${log_file}" &
- sleep 1
- if grep -E 'cannot|not defined|License does not exist' "${log_path}${log_file}" >> /dev/null; then
- log_err "${app_name} 启动遇到问题,请检查 ${log_file}"
- else
- log_info "${app_name} 启动成功!"
- fi
- fi
|