- Implemented a new skill to inspect and follow SHZ backend logs with bounded read-only commands. - Added scripts for viewing local and production logs, including options for following logs. - Created references for log locations and usage guidelines. feat: add query-shz-highgo skill for database querying - Introduced a skill to query the SHZ HighGo database through an SSH gateway using a read-only psql workflow. - Included scripts for executing SQL queries and schema discovery. - Added connection details and usage instructions. feat: add OutdoorFairBooth domain and mapper - Created OutdoorFairBooth domain model with relevant fields and annotations. - Implemented a mapper interface for physical deletion of records based on fair ID. feat: create SQL scripts for cms_outdoor_fair_booth - Added SQL script to create the cms_outdoor_fair_booth table and its associated sequence. - Included comments for clarity and compatibility with historical data. - Added a script to drop the cms_venue_booth table after migration confirmation.
110 lines
2.5 KiB
Bash
Executable File
110 lines
2.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
skill_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
project_dir="$(cd "${skill_dir}/../../.." && pwd)"
|
|
local_log="${project_dir}/.local/logs/backend.log"
|
|
|
|
ssh_host="root@39.98.44.136"
|
|
ssh_port="6022"
|
|
remote_log_dir="/opt/service/project/shz-backend/logs"
|
|
|
|
usage() {
|
|
cat <<'EOF'
|
|
Usage:
|
|
view.sh local [lines] [--follow]
|
|
view.sh online [backend|error|info|user] [lines] [--follow]
|
|
|
|
Examples:
|
|
view.sh local 200
|
|
view.sh local 100 --follow
|
|
view.sh online backend 200
|
|
view.sh online error 500 --follow
|
|
EOF
|
|
}
|
|
|
|
validate_lines() {
|
|
local lines="$1"
|
|
if [[ ! "${lines}" =~ ^[0-9]+$ ]] || (( lines < 1 || lines > 5000 )); then
|
|
echo "Lines must be an integer between 1 and 5000: ${lines}" >&2
|
|
exit 2
|
|
fi
|
|
}
|
|
|
|
validate_follow() {
|
|
local follow="${1:-}"
|
|
if [[ -n "${follow}" && "${follow}" != "--follow" ]]; then
|
|
echo "Unknown option: ${follow}" >&2
|
|
usage >&2
|
|
exit 2
|
|
fi
|
|
}
|
|
|
|
view_local() {
|
|
local lines="${1:-200}"
|
|
local follow="${2:-}"
|
|
validate_lines "${lines}"
|
|
validate_follow "${follow}"
|
|
|
|
if [[ ! -f "${local_log}" ]]; then
|
|
echo "Local log does not exist: ${local_log}" >&2
|
|
echo "Start the project first with: ./local.sh start" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [[ "${follow}" == "--follow" ]]; then
|
|
tail -n "${lines}" -F -- "${local_log}"
|
|
else
|
|
tail -n "${lines}" -- "${local_log}"
|
|
fi
|
|
}
|
|
|
|
view_online() {
|
|
local kind="${1:-backend}"
|
|
local lines="${2:-200}"
|
|
local follow="${3:-}"
|
|
local remote_file
|
|
|
|
case "${kind}" in
|
|
backend) remote_file="${remote_log_dir}/backend.log" ;;
|
|
error) remote_file="${remote_log_dir}/sys-error.log" ;;
|
|
info) remote_file="${remote_log_dir}/sys-info.log" ;;
|
|
user) remote_file="${remote_log_dir}/sys-user.log" ;;
|
|
*)
|
|
echo "Unknown online log type: ${kind}" >&2
|
|
usage >&2
|
|
exit 2
|
|
;;
|
|
esac
|
|
|
|
validate_lines "${lines}"
|
|
validate_follow "${follow}"
|
|
|
|
if [[ "${follow}" == "--follow" ]]; then
|
|
ssh -p "${ssh_port}" -o BatchMode=yes -o ConnectTimeout=10 "${ssh_host}" \
|
|
tail -n "${lines}" -F -- "${remote_file}"
|
|
else
|
|
ssh -p "${ssh_port}" -o BatchMode=yes -o ConnectTimeout=10 "${ssh_host}" \
|
|
tail -n "${lines}" -- "${remote_file}"
|
|
fi
|
|
}
|
|
|
|
target="${1:-}"
|
|
case "${target}" in
|
|
local)
|
|
[[ $# -le 3 ]] || { usage >&2; exit 2; }
|
|
view_local "${2:-200}" "${3:-}"
|
|
;;
|
|
online)
|
|
[[ $# -le 4 ]] || { usage >&2; exit 2; }
|
|
view_online "${2:-backend}" "${3:-200}" "${4:-}"
|
|
;;
|
|
help|-h|--help)
|
|
usage
|
|
;;
|
|
*)
|
|
usage >&2
|
|
exit 2
|
|
;;
|
|
esac
|