feat: append script lifecycle events to smart_ide logs/ia_dev.log when embedded
This commit is contained in:
parent
e8c0db2200
commit
756bab0cd8
@ -8,6 +8,12 @@ cat > /dev/null
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
IA_DEV="$(cd "${SCRIPT_DIR}/../.." && pwd)"
|
||||
if [[ -f "${IA_DEV}/lib/smart_ide_logs.sh" ]]; then
|
||||
# shellcheck source=../../lib/smart_ide_logs.sh
|
||||
source "${IA_DEV}/lib/smart_ide_logs.sh"
|
||||
smart_ide_logs_begin "$IA_DEV" "$0" "$*"
|
||||
smart_ide_logs_register_exit_trap
|
||||
fi
|
||||
|
||||
CONTENT=""
|
||||
for spool in "${IA_DEV}/projects/"*/data/issues; do
|
||||
|
||||
@ -30,3 +30,10 @@ export DATA_NOTARY_AI_RESPONDED_DIR
|
||||
export PROJECT_ID
|
||||
export IA_DEV_ROOT
|
||||
export PROJECT_ROOT
|
||||
|
||||
if [[ -f "${IA_DEV_ROOT}/lib/smart_ide_logs.sh" ]]; then
|
||||
# shellcheck source=../../lib/smart_ide_logs.sh
|
||||
source "${IA_DEV_ROOT}/lib/smart_ide_logs.sh"
|
||||
smart_ide_logs_begin "$IA_DEV_ROOT" "${BASH_SOURCE[1]}" "$*"
|
||||
smart_ide_logs_register_exit_trap
|
||||
fi
|
||||
|
||||
@ -7,6 +7,10 @@ SCRIPT_REAL="$(readlink -f "${BASH_SOURCE[0]:-$0}" 2>/dev/null || realpath "${BA
|
||||
DEPLOY_DIR="$(cd "$(dirname "$SCRIPT_REAL")" && pwd)"
|
||||
IA_DEV_ROOT="$(cd "$DEPLOY_DIR/.." && pwd)"
|
||||
|
||||
# shellcheck source=../lib/smart_ide_logs.sh
|
||||
source "${IA_DEV_ROOT}/lib/smart_ide_logs.sh"
|
||||
smart_ide_logs_begin "$IA_DEV_ROOT" "$0" "$*"
|
||||
|
||||
# Optional first arg: project id (must exist as projects/<id>/conf.json); then re-exec from project root
|
||||
if [[ -n "${1:-}" && -f "${IA_DEV_ROOT}/projects/${1}/conf.json" && ! "$1" =~ ^(main|test|pprod|prod)$ ]]; then
|
||||
export IA_PROJECT_ID="$1"
|
||||
@ -90,6 +94,8 @@ tmp1="$(mktemp -t branch-align-test.XXXXXX)"
|
||||
tmp2="$(mktemp -t branch-align-pprod.XXXXXX)"
|
||||
tmp3="$(mktemp -t branch-align-prod.XXXXXX)"
|
||||
cleanup() {
|
||||
local ec=$?
|
||||
smart_ide_log_end_with_status "$ec"
|
||||
rm -f "$tmp1" "$tmp2" "$tmp3"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
@ -8,6 +8,11 @@ SCRIPT_REAL="$(readlink -f "${BASH_SOURCE[0]:-$0}" 2>/dev/null || realpath "${BA
|
||||
DEPLOY_DIR="$(cd "$(dirname "$SCRIPT_REAL")" && pwd)"
|
||||
IA_DEV_ROOT="$(cd "$DEPLOY_DIR/.." && pwd)"
|
||||
|
||||
# shellcheck source=../lib/smart_ide_logs.sh
|
||||
source "${IA_DEV_ROOT}/lib/smart_ide_logs.sh"
|
||||
smart_ide_logs_begin "$IA_DEV_ROOT" "$0" "$*"
|
||||
smart_ide_logs_register_exit_trap
|
||||
|
||||
# Optional first arg: project id (must exist as projects/<id>/conf.json)
|
||||
if [[ -n "${1:-}" && -f "${IA_DEV_ROOT}/projects/${1}/conf.json" && "$1" != *.* ]]; then
|
||||
export IA_PROJECT_ID="$1"
|
||||
|
||||
@ -7,6 +7,11 @@ SCRIPT_REAL="$(readlink -f "${BASH_SOURCE[0]:-$0}" 2>/dev/null || realpath "${BA
|
||||
DEPLOY_DIR="$(cd "$(dirname "$SCRIPT_REAL")" && pwd)"
|
||||
IA_DEV_ROOT="$(cd "$DEPLOY_DIR/.." && pwd)"
|
||||
|
||||
# shellcheck source=../lib/smart_ide_logs.sh
|
||||
source "${IA_DEV_ROOT}/lib/smart_ide_logs.sh"
|
||||
smart_ide_logs_begin "$IA_DEV_ROOT" "$0" "$*"
|
||||
smart_ide_logs_register_exit_trap
|
||||
|
||||
# Optional first arg: project id (must exist as projects/<id>/conf.json); then re-exec from project root
|
||||
if [[ -n "${1:-}" && -f "${IA_DEV_ROOT}/projects/${1}/conf.json" ]]; then
|
||||
export IA_PROJECT_ID="$1"
|
||||
|
||||
@ -8,6 +8,11 @@ SCRIPT_REAL="$(readlink -f "${BASH_SOURCE[0]:-$0}" 2>/dev/null || realpath "${BA
|
||||
DEPLOY_IA="$(cd "$(dirname "$SCRIPT_REAL")" && pwd)"
|
||||
IA_DEV_ROOT="$(cd "$DEPLOY_IA/.." && pwd)"
|
||||
|
||||
# shellcheck source=../lib/smart_ide_logs.sh
|
||||
source "${IA_DEV_ROOT}/lib/smart_ide_logs.sh"
|
||||
smart_ide_logs_begin "$IA_DEV_ROOT" "$0" "$*"
|
||||
smart_ide_logs_register_exit_trap
|
||||
|
||||
# Optional first arg: project id (must exist as projects/<id>/conf.json)
|
||||
if [[ -n "${1:-}" && ! "$1" =~ ^(pprod|prod)$ && -f "${IA_DEV_ROOT}/projects/${1}/conf.json" ]]; then
|
||||
export IA_PROJECT_ID="$1"
|
||||
|
||||
@ -8,6 +8,10 @@ SCRIPT_REAL="$(readlink -f "${BASH_SOURCE[0]:-$0}" 2>/dev/null || realpath "${BA
|
||||
DEPLOY_DIR="$(cd "$(dirname "$SCRIPT_REAL")" && pwd)"
|
||||
IA_DEV_ROOT="$(cd "$DEPLOY_DIR/.." && pwd)"
|
||||
|
||||
# shellcheck source=../lib/smart_ide_logs.sh
|
||||
source "${IA_DEV_ROOT}/lib/smart_ide_logs.sh"
|
||||
smart_ide_logs_begin "$IA_DEV_ROOT" "$0" "$*"
|
||||
|
||||
# shellcheck source=lib/deploy-methodology.sh
|
||||
source "${DEPLOY_DIR}/lib/deploy-methodology.sh"
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
## `ssh.sh`
|
||||
|
||||
Canonical SSH/SCP helpers (`ssh_run`, `scp_copy`, `require_ssh_key`, `ssh_common_opts`) used across projects.
|
||||
**LeCoffre** : `deploy/scripts_v2/_lib/ssh.sh` sources `ia_dev/deploy/lib/ssh.sh` when the submodule path `ia_dev/deploy/lib/ssh.sh` exists from the repo root; otherwise it embeds the same implementation.
|
||||
**LeCoffre** : `deploy/scripts_v2/_lib/ssh.sh` sources `ia_dev/deploy/lib/ssh.sh` when the path `ia_dev/deploy/lib/ssh.sh` exists from the repo root; otherwise it embeds the same implementation.
|
||||
|
||||
## `deploy-log.sh`
|
||||
|
||||
|
||||
@ -21,6 +21,12 @@ deploy_script_tee_log_if_requested() {
|
||||
printf '%s\n' "=== LeCoffre deploy log ==="
|
||||
printf '%s\n' "environment=${deploy_env:-<unset>} started_at=${DEPLOY_STARTED_AT:-} project_root=${project_root}"
|
||||
} >"$log_file"
|
||||
_IA_DEV_DEPLOY_LOG="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
if [[ -f "${_IA_DEV_DEPLOY_LOG}/lib/smart_ide_logs.sh" ]]; then
|
||||
# shellcheck source=../../lib/smart_ide_logs.sh
|
||||
SMART_IDE_LOG_IA_DEV_ROOT="$_IA_DEV_DEPLOY_LOG" source "${_IA_DEV_DEPLOY_LOG}/lib/smart_ide_logs.sh"
|
||||
smart_ide_log_event "deploy_script_tee_log project_root=${project_root} log_file=${log_file}"
|
||||
fi
|
||||
exec > >(tee -a "$log_file")
|
||||
info "[deploy] Teeing output to ${log_file}"
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
# Shared SSH/SCP helpers for deploy scripts (ProxyJump, BatchMode, keepalive).
|
||||
# Sourced by project deploy/_lib/ssh.sh when ia_dev is present as submodule/sibling.
|
||||
# Sourced by project deploy/_lib/ssh.sh when ia_dev is present under the repo root (or sibling layout).
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
|
||||
@ -10,6 +10,11 @@ SCRIPT_REAL="$(readlink -f "${BASH_SOURCE[0]:-$0}" 2>/dev/null || realpath "${BA
|
||||
DEPLOY_DIR="$(cd "$(dirname "$SCRIPT_REAL")" && pwd)"
|
||||
IA_DEV_ROOT="$(cd "$DEPLOY_DIR/.." && pwd)"
|
||||
|
||||
# shellcheck source=../lib/smart_ide_logs.sh
|
||||
source "${IA_DEV_ROOT}/lib/smart_ide_logs.sh"
|
||||
smart_ide_logs_begin "$IA_DEV_ROOT" "$0" "$*"
|
||||
smart_ide_logs_register_exit_trap
|
||||
|
||||
_ORCH_TAG="[orchestrator]"
|
||||
|
||||
# shellcheck source=lib/deploy-methodology.sh
|
||||
@ -60,6 +65,7 @@ if [[ -n "$PROJECT_ORCH_REL" && "$PROJECT_ORCH_REL" != "null" ]]; then
|
||||
echo "${_ORCH_TAG}[WARN] deploy.hooks.phases is non-empty but project_orchestrator_path takes precedence; phases are ignored." >&2
|
||||
fi
|
||||
echo "${_ORCH_TAG} Project orchestrator: ${PROJECT_ORCH_REL} $*"
|
||||
smart_ide_log_event "HANDOFF project_orchestrator ${PROJECT_ORCH_ABS} $*"
|
||||
exec bash "$PROJECT_ORCH_ABS" "$@"
|
||||
fi
|
||||
|
||||
@ -71,12 +77,14 @@ fi
|
||||
PHASE_COUNT="$(jq '.deploy.hooks.phases // [] | length' "$CONF")"
|
||||
if [[ "$PHASE_COUNT" == "0" ]]; then
|
||||
echo "${_ORCH_TAG}[WARN] deploy.project_orchestrator_path unset; falling back to deploy_script_path only." >&2
|
||||
smart_ide_log_event "HANDOFF deploy_script_path ${DEPLOY_SCRIPT_PATH} $*"
|
||||
exec bash "$DEPLOY_SCRIPT_PATH" "$@"
|
||||
fi
|
||||
|
||||
mapfile -t PHASE_SCRIPTS < <(jq -r '.deploy.hooks.phases[]? | if type == "string" then . elif type == "object" and (.run | type == "string") then .run else empty end' "$CONF")
|
||||
|
||||
if [[ ${#PHASE_SCRIPTS[@]} -eq 0 ]]; then
|
||||
smart_ide_log_event "HANDOFF deploy_script_path ${DEPLOY_SCRIPT_PATH} $*"
|
||||
exec bash "$DEPLOY_SCRIPT_PATH" "$@"
|
||||
fi
|
||||
|
||||
|
||||
@ -11,6 +11,10 @@ SCRIPT_REAL="$(readlink -f "${BASH_SOURCE[0]:-$0}" 2>/dev/null || realpath "${BA
|
||||
DEPLOY_DIR="$(cd "$(dirname "$SCRIPT_REAL")" && pwd)"
|
||||
IA_DEV_ROOT="$(cd "$DEPLOY_DIR/.." && pwd)"
|
||||
|
||||
# shellcheck source=../lib/smart_ide_logs.sh
|
||||
source "${IA_DEV_ROOT}/lib/smart_ide_logs.sh"
|
||||
smart_ide_logs_begin "$IA_DEV_ROOT" "$0" "$*"
|
||||
|
||||
# Optional project id: --project <id> or first positional if projects/<id>/conf.json exists
|
||||
while [[ $# -gt 0 ]]; do
|
||||
if [[ "$1" == --project ]]; then
|
||||
@ -151,6 +155,8 @@ fi
|
||||
|
||||
msg_file="$(mktemp -t pousse-commit-msg.XXXXXX)"
|
||||
cleanup() {
|
||||
local ec=$?
|
||||
smart_ide_log_end_with_status "$ec"
|
||||
rm -f "$msg_file"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
@ -6,4 +6,8 @@ set -euo pipefail
|
||||
|
||||
SCRIPT_REAL="$(readlink -f "${BASH_SOURCE[0]:-$0}" 2>/dev/null || realpath "${BASH_SOURCE[0]:-$0}" 2>/dev/null || echo "${BASH_SOURCE[0]:-$0}")"
|
||||
DEPLOY_DIR="$(cd "$(dirname "$SCRIPT_REAL")" && pwd)"
|
||||
IA_DEV_ROOT="$(cd "$DEPLOY_DIR/.." && pwd)"
|
||||
# shellcheck source=../lib/smart_ide_logs.sh
|
||||
source "${IA_DEV_ROOT}/lib/smart_ide_logs.sh"
|
||||
smart_ide_logs_begin "$IA_DEV_ROOT" "$0" "$*"
|
||||
exec "$DEPLOY_DIR/orchestrator.sh" "$@"
|
||||
|
||||
@ -6,6 +6,13 @@ set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="${BASH_SOURCE%/*}"
|
||||
[[ -d "$SCRIPT_DIR" ]] || SCRIPT_DIR=.
|
||||
IA_DEV_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
if [[ -f "${IA_DEV_ROOT}/lib/smart_ide_logs.sh" ]]; then
|
||||
# shellcheck source=../../lib/smart_ide_logs.sh
|
||||
source "${IA_DEV_ROOT}/lib/smart_ide_logs.sh"
|
||||
smart_ide_logs_begin "$IA_DEV_ROOT" "$0" "$*"
|
||||
smart_ide_logs_register_exit_trap
|
||||
fi
|
||||
LIB_DIR="$(cd "$SCRIPT_DIR/../_lib" && pwd)"
|
||||
# shellcheck source=../_lib/ssh.sh
|
||||
source "$LIB_DIR/ssh.sh"
|
||||
|
||||
@ -4,6 +4,12 @@
|
||||
set -euo pipefail
|
||||
|
||||
IA_DEV_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
if [[ -f "${IA_DEV_ROOT}/lib/smart_ide_logs.sh" ]]; then
|
||||
# shellcheck source=../../lib/smart_ide_logs.sh
|
||||
source "${IA_DEV_ROOT}/lib/smart_ide_logs.sh"
|
||||
smart_ide_logs_begin "$IA_DEV_ROOT" "$0" "$*"
|
||||
smart_ide_logs_register_exit_trap
|
||||
fi
|
||||
# shellcheck source=deploy/_lib/ssh.sh
|
||||
source "${IA_DEV_ROOT}/deploy/_lib/ssh.sh"
|
||||
|
||||
|
||||
@ -33,6 +33,14 @@ fi
|
||||
export PROJECT_LOGS_DIR
|
||||
export DATA_ISSUES_DIR
|
||||
|
||||
if [[ -f "${GITEA_ISSUES_DIR}/../lib/smart_ide_logs.sh" ]]; then
|
||||
# shellcheck source=../lib/smart_ide_logs.sh
|
||||
source "${GITEA_ISSUES_DIR}/../lib/smart_ide_logs.sh"
|
||||
_IA_DEV_ROOT_FOR_LOG="$(cd "${GITEA_ISSUES_DIR}/.." && pwd)"
|
||||
smart_ide_logs_begin "$_IA_DEV_ROOT_FOR_LOG" "${BASH_SOURCE[1]}" "$*"
|
||||
smart_ide_logs_register_exit_trap
|
||||
fi
|
||||
|
||||
# Load token: GITEA_TOKEN env, then project config git.token_file (path relative to ia_dev root), then default
|
||||
load_gitea_token() {
|
||||
if [[ -n "${GITEA_TOKEN:-}" ]]; then
|
||||
|
||||
@ -5,4 +5,10 @@ set -euo pipefail
|
||||
GITEA_ISSUES_DIR="${GITEA_ISSUES_DIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)}"
|
||||
export GITEA_ISSUES_DIR
|
||||
export REPO_ROOT="${GITEA_ISSUES_DIR}/.."
|
||||
_IA_FOR_LOG="$(cd "${GITEA_ISSUES_DIR}/.." && pwd)"
|
||||
if [[ -f "${_IA_FOR_LOG}/lib/smart_ide_logs.sh" ]]; then
|
||||
# shellcheck source=../lib/smart_ide_logs.sh
|
||||
source "${_IA_FOR_LOG}/lib/smart_ide_logs.sh"
|
||||
smart_ide_logs_begin "$_IA_FOR_LOG" "$0" "$*"
|
||||
fi
|
||||
exec python3 "${GITEA_ISSUES_DIR}/mail-create-issue-from-email.py" "$@"
|
||||
|
||||
@ -9,4 +9,10 @@ if [ $# -lt 1 ]; then
|
||||
echo "Usage: $0 <uid>" >&2
|
||||
exit 1
|
||||
fi
|
||||
_IA_FOR_LOG="$(cd "${GITEA_ISSUES_DIR}/.." && pwd)"
|
||||
if [[ -f "${_IA_FOR_LOG}/lib/smart_ide_logs.sh" ]]; then
|
||||
# shellcheck source=../lib/smart_ide_logs.sh
|
||||
source "${_IA_FOR_LOG}/lib/smart_ide_logs.sh"
|
||||
smart_ide_logs_begin "$_IA_FOR_LOG" "$0" "$*"
|
||||
fi
|
||||
exec python3 "${GITEA_ISSUES_DIR}/mail-get-thread.py" "$1"
|
||||
|
||||
@ -5,4 +5,10 @@ GITEA_ISSUES_DIR="${GITEA_ISSUES_DIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")" && p
|
||||
# REPO_ROOT = ia_dev so mail_common.repo_root() finds .secrets under ia_dev
|
||||
export GITEA_ISSUES_DIR
|
||||
export REPO_ROOT="${GITEA_ISSUES_DIR}/.."
|
||||
_IA_FOR_LOG="$(cd "${GITEA_ISSUES_DIR}/.." && pwd)"
|
||||
if [[ -f "${_IA_FOR_LOG}/lib/smart_ide_logs.sh" ]]; then
|
||||
# shellcheck source=../lib/smart_ide_logs.sh
|
||||
source "${_IA_FOR_LOG}/lib/smart_ide_logs.sh"
|
||||
smart_ide_logs_begin "$_IA_FOR_LOG" "$0" "$*"
|
||||
fi
|
||||
exec python3 "${GITEA_ISSUES_DIR}/mail-list-unread.py"
|
||||
|
||||
@ -5,4 +5,10 @@ set -euo pipefail
|
||||
GITEA_ISSUES_DIR="${GITEA_ISSUES_DIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)}"
|
||||
export GITEA_ISSUES_DIR
|
||||
export REPO_ROOT="${GITEA_ISSUES_DIR}/.."
|
||||
_IA_FOR_LOG="$(cd "${GITEA_ISSUES_DIR}/.." && pwd)"
|
||||
if [[ -f "${_IA_FOR_LOG}/lib/smart_ide_logs.sh" ]]; then
|
||||
# shellcheck source=../lib/smart_ide_logs.sh
|
||||
source "${_IA_FOR_LOG}/lib/smart_ide_logs.sh"
|
||||
smart_ide_logs_begin "$_IA_FOR_LOG" "$0" "$*"
|
||||
fi
|
||||
exec python3 "${GITEA_ISSUES_DIR}/mail-mark-read.py" "$@"
|
||||
|
||||
@ -5,4 +5,10 @@ set -euo pipefail
|
||||
GITEA_ISSUES_DIR="${GITEA_ISSUES_DIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)}"
|
||||
export GITEA_ISSUES_DIR
|
||||
export REPO_ROOT="${GITEA_ISSUES_DIR}/.."
|
||||
_IA_FOR_LOG="$(cd "${GITEA_ISSUES_DIR}/.." && pwd)"
|
||||
if [[ -f "${_IA_FOR_LOG}/lib/smart_ide_logs.sh" ]]; then
|
||||
# shellcheck source=../lib/smart_ide_logs.sh
|
||||
source "${_IA_FOR_LOG}/lib/smart_ide_logs.sh"
|
||||
smart_ide_logs_begin "$_IA_FOR_LOG" "$0" "$*"
|
||||
fi
|
||||
exec python3 "${GITEA_ISSUES_DIR}/mail-send-reply.py" "$@"
|
||||
|
||||
@ -10,4 +10,10 @@ set -euo pipefail
|
||||
GITEA_ISSUES_DIR="${GITEA_ISSUES_DIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)}"
|
||||
export GITEA_ISSUES_DIR
|
||||
export REPO_ROOT="${GITEA_ISSUES_DIR}/.."
|
||||
_IA_FOR_LOG="$(cd "${GITEA_ISSUES_DIR}/.." && pwd)"
|
||||
if [[ -f "${_IA_FOR_LOG}/lib/smart_ide_logs.sh" ]]; then
|
||||
# shellcheck source=../lib/smart_ide_logs.sh
|
||||
source "${_IA_FOR_LOG}/lib/smart_ide_logs.sh"
|
||||
smart_ide_logs_begin "$_IA_FOR_LOG" "$0" "$*"
|
||||
fi
|
||||
exec python3 "${GITEA_ISSUES_DIR}/mail-thread-log.py" "$@"
|
||||
|
||||
@ -9,4 +9,10 @@ set -euo pipefail
|
||||
GITEA_ISSUES_DIR="${GITEA_ISSUES_DIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)}"
|
||||
export GITEA_ISSUES_DIR
|
||||
export REPO_ROOT="${GITEA_ISSUES_DIR}/.."
|
||||
_IA_FOR_LOG="$(cd "${GITEA_ISSUES_DIR}/.." && pwd)"
|
||||
if [[ -f "${_IA_FOR_LOG}/lib/smart_ide_logs.sh" ]]; then
|
||||
# shellcheck source=../lib/smart_ide_logs.sh
|
||||
source "${_IA_FOR_LOG}/lib/smart_ide_logs.sh"
|
||||
smart_ide_logs_begin "$_IA_FOR_LOG" "$0" "$*"
|
||||
fi
|
||||
exec python3 "${GITEA_ISSUES_DIR}/mail-to-issue.py"
|
||||
|
||||
@ -5,4 +5,10 @@ set -euo pipefail
|
||||
GITEA_ISSUES_DIR="${GITEA_ISSUES_DIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)}"
|
||||
export GITEA_ISSUES_DIR
|
||||
export REPO_ROOT="${GITEA_ISSUES_DIR}/.."
|
||||
_IA_FOR_LOG="$(cd "${GITEA_ISSUES_DIR}/.." && pwd)"
|
||||
if [[ -f "${_IA_FOR_LOG}/lib/smart_ide_logs.sh" ]]; then
|
||||
# shellcheck source=../lib/smart_ide_logs.sh
|
||||
source "${_IA_FOR_LOG}/lib/smart_ide_logs.sh"
|
||||
smart_ide_logs_begin "$_IA_FOR_LOG" "$0" "$*"
|
||||
fi
|
||||
exec python3 "${GITEA_ISSUES_DIR}/write-response-spooler.py" "$@"
|
||||
|
||||
51
lib/smart_ide_logs.sh
Normal file
51
lib/smart_ide_logs.sh
Normal file
@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env bash
|
||||
# Append one line per event to <smart_ide>/logs/ia_dev.log when ia_dev lives inside smart_ide.
|
||||
# Usage: export SMART_IDE_LOG_IA_DEV_ROOT after cd to ia_dev root, then smart_ide_log_event / smart_ide_logs_begin.
|
||||
|
||||
smart_ide_logs_resolve_root_for_ia_dev() {
|
||||
local ia_root="${1:?}"
|
||||
local parent base_name
|
||||
base_name="$(basename "$ia_root")"
|
||||
if [[ "$base_name" != "ia_dev" ]]; then
|
||||
return 1
|
||||
fi
|
||||
parent="$(cd "$ia_root/.." && pwd)"
|
||||
if [[ -f "${parent}/cron/git-pull-wrapper.sh" ]] || [[ -d "${parent}/projects/smart_ide" ]]; then
|
||||
printf '%s\n' "$parent"
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
smart_ide_log_event() {
|
||||
local ia_root="${SMART_IDE_LOG_IA_DEV_ROOT:-}"
|
||||
if [[ -z "$ia_root" ]]; then
|
||||
return 0
|
||||
fi
|
||||
local smart_root logf
|
||||
smart_root="$(smart_ide_logs_resolve_root_for_ia_dev "$ia_root" 2>/dev/null)" || return 0
|
||||
logf="${smart_root}/logs/ia_dev.log"
|
||||
mkdir -p "$(dirname "$logf")"
|
||||
printf '%s %s\n' "$(date -Iseconds)" "$*" >>"$logf"
|
||||
}
|
||||
|
||||
smart_ide_logs_begin() {
|
||||
export SMART_IDE_LOG_IA_DEV_ROOT="${1:?}"
|
||||
export SMART_IDE_LOG_SCRIPT_PATH="${2:?}"
|
||||
shift 2
|
||||
smart_ide_log_event "START ${SMART_IDE_LOG_SCRIPT_PATH} $*"
|
||||
}
|
||||
|
||||
smart_ide_logs_register_exit_trap() {
|
||||
trap 'smart_ide_logs_on_exit_trap' EXIT
|
||||
}
|
||||
|
||||
smart_ide_logs_on_exit_trap() {
|
||||
local ec=$?
|
||||
smart_ide_log_event "END ${SMART_IDE_LOG_SCRIPT_PATH:-?} exit=${ec}"
|
||||
}
|
||||
|
||||
smart_ide_log_end_with_status() {
|
||||
local ec="${1:?}"
|
||||
smart_ide_log_event "END ${SMART_IDE_LOG_SCRIPT_PATH:-${0:-?}} exit=${ec}"
|
||||
}
|
||||
@ -5,6 +5,14 @@
|
||||
# Syslog identifier: lpldf-https-watch (for SIEM / Wazuh-style log collection).
|
||||
set -euo pipefail
|
||||
|
||||
_IA_DEV_TOOLS="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
if [[ -f "${_IA_DEV_TOOLS}/lib/smart_ide_logs.sh" ]]; then
|
||||
# shellcheck source=../lib/smart_ide_logs.sh
|
||||
source "${_IA_DEV_TOOLS}/lib/smart_ide_logs.sh"
|
||||
smart_ide_logs_begin "$_IA_DEV_TOOLS" "$0" "$*"
|
||||
smart_ide_logs_register_exit_trap
|
||||
fi
|
||||
|
||||
readonly WATCH_URL="${WATCH_URL:-https://xn--lespetitesleonsdefrdric-89b1db.fr/}"
|
||||
readonly STATE_DIR="${STATE_DIR:-/var/lib/lpldf-https-watch}"
|
||||
readonly STATE_FILE="${STATE_DIR}/last_state"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user