|
@@ -0,0 +1,82 @@
|
|
|
+#!/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 [[ ! -d "$base_dir/lib" ]]; then
|
|
|
+ log_err "缺少lib文件夹,请查证后重新运行此脚本" && exit 1
|
|
|
+fi
|
|
|
+
|
|
|
+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 [[ ! -f "$base_dir/license/license_key.json" ]]; then
|
|
|
+ log_warn "您可能未开始、或未完成授权过程.现在生成key,请之后完成授权过程再启动此脚本"
|
|
|
+ # 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 server --config-file=$base_dir/config/config.xml &> "${log_path}${log_file}" &
|
|
|
+ ./status.sh
|
|
|
+fi
|