Compare commits
10
Commits
fbde9a19ab
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d3d9614825 | ||
|
|
3acdc81891 | ||
|
|
dcaaf46ef3 | ||
|
|
c8111645e4 | ||
|
|
729b24edd8 | ||
|
|
8a1bc3cba2 | ||
|
|
48601ee943 | ||
|
|
82f1ddeec3 | ||
|
|
90677d9aba | ||
|
|
fa1d33d126 |
+1
-1
@@ -501,7 +501,7 @@ async def get_odoo_log_summary(uuid: str):
|
||||
# --- Main logic ---
|
||||
try:
|
||||
# Last 500 lines from Odoo log
|
||||
last_500_lines = read_last_lines(odoo_log_file, 500)
|
||||
last_500_lines = read_last_lines(odoo_log_file, 5000)
|
||||
important_odoo_lines = [
|
||||
line for line in last_500_lines if is_important_line(line)
|
||||
]
|
||||
|
||||
Executable
+58
@@ -0,0 +1,58 @@
|
||||
#!/bin/bash
|
||||
# checkFilestore <UUID> — compare container filestore vs host disk via md5
|
||||
|
||||
check_one() {
|
||||
local UUID="$1"
|
||||
|
||||
FILESTORE_HOST="/4server/data/$UUID/odoo/odoo-web-data/filestore/$UUID"
|
||||
|
||||
[[ -d "$FILESTORE_HOST" ]] || { echo "ERROR: host filestore not found: $FILESTORE_HOST"; exit 2; }
|
||||
doas docker ps --format "{{.Names}}" | grep -q "^${UUID}$" \
|
||||
|| { echo "ERROR: container $UUID is not running"; exit 2; }
|
||||
|
||||
# Read data_dir from odoo.conf inside the container, fall back to default
|
||||
DATA_DIR=$(doas docker exec "$UUID" sh -c \
|
||||
'for f in /etc/odoo.conf /etc/odoo/odoo.conf /opt/odoo/etc/odoo.conf; do
|
||||
grep -E "^data_dir" "$f" 2>/dev/null | cut -d= -f2- | xargs && break
|
||||
done')
|
||||
DATA_DIR="${DATA_DIR:-/home/odoo/.local/share/Odoo}"
|
||||
FILESTORE_CONTAINER="$DATA_DIR/filestore/$UUID"
|
||||
MOUNT_HOST=$(doas docker inspect "$UUID" --format '{{json .Mounts}}' \
|
||||
| jq -r --arg dest "$DATA_DIR" '.[] | select(.Type=="bind") | select(.Destination==$dest) | .Source')
|
||||
echo "ODOO USES : $FILESTORE_CONTAINER"
|
||||
echo "Docker maps to : $DATA_DIR"
|
||||
echo ""
|
||||
echo "Docker mapped to : ${MOUNT_HOST:-<no matching mount found>}"
|
||||
|
||||
echo "Hashing container filestore..."
|
||||
MD5_CONTAINER=$(doas docker exec "$UUID" sh -c \
|
||||
"find $FILESTORE_CONTAINER -type f | sort | xargs md5sum 2>/dev/null | awk '{print \$1}'" | md5sum | cut -d' ' -f1)
|
||||
|
||||
echo "Hashing host filestore..."
|
||||
MD5_HOST=$(find "$FILESTORE_HOST" -type f | sort | xargs md5sum 2>/dev/null | awk '{print $1}' | md5sum | cut -d' ' -f1)
|
||||
|
||||
echo "Container : $MD5_CONTAINER"
|
||||
echo "Host : $MD5_HOST"
|
||||
|
||||
[[ "$MD5_CONTAINER" == "$MD5_HOST" ]] && echo "OK: filestores match" || { echo "FAIL: mismatch"; return 3; }
|
||||
}
|
||||
|
||||
if [[ -n "${1-}" ]]; then
|
||||
check_one "$1"
|
||||
else
|
||||
for dir in /4server/data/00*/; do
|
||||
UUID=$(basename "$dir")
|
||||
result=$(check_one "$UUID" 2>&1)
|
||||
if echo "$result" | grep -q "OK: filestores match"; then
|
||||
echo "$UUID OK"
|
||||
elif echo "$result" | grep -q "not running"; then
|
||||
echo "$UUID NOT RUNNING"
|
||||
elif echo "$result" | grep -q "host filestore not found"; then
|
||||
echo "$UUID NO FILESTORE"
|
||||
elif echo "$result" | grep -q "cannot query DB"; then
|
||||
echo "$UUID DB ERROR"
|
||||
else
|
||||
echo "$UUID MISMATCH"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
Executable
+43
@@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
# rotateLogs — rotate odoo.log for all UUID containers, keep 4 weeks
|
||||
# Runs as a daemon: waits for midnight, rotates, then waits for next midnight
|
||||
|
||||
RETENTION_DAYS=28
|
||||
|
||||
wait_for_midnight() {
|
||||
ELAPSED=$(( $(date +%H) * 3600 + $(date +%M) * 60 + $(date +%S) ))
|
||||
SLEEP=$(( 86400 - ELAPSED ))
|
||||
echo "Waiting ${SLEEP}s until midnight..."
|
||||
sleep "$SLEEP"
|
||||
}
|
||||
|
||||
while true; do
|
||||
wait_for_midnight
|
||||
|
||||
for log in /4server/data/00*/logs/odoo.log; do
|
||||
[[ -f "$log" ]] || continue
|
||||
DIR=$(dirname "$log")
|
||||
UUID=$(basename "$(dirname "$DIR")")
|
||||
|
||||
STAMP=$(date '+%Y-%m-%d_%H-%M')
|
||||
ARCHIVE="$DIR/odoo.log.$STAMP"
|
||||
|
||||
# Copy preserving permissions, then truncate the live log
|
||||
PERMS=$(stat -c '%a' "$log")
|
||||
OWNER=$(stat -c '%u:%g' "$log")
|
||||
cp "$log" "$ARCHIVE"
|
||||
: > "$log"
|
||||
|
||||
# Compress the archive, restore original ownership and permissions
|
||||
gzip "$ARCHIVE"
|
||||
chmod "$PERMS" "${ARCHIVE}.gz"
|
||||
chown "$OWNER" "${ARCHIVE}.gz"
|
||||
|
||||
echo "$UUID rotated -> $(basename "${ARCHIVE}.gz")"
|
||||
|
||||
# Delete rotated logs older than 4 weeks
|
||||
find "$DIR" -name 'odoo.log.*.gz' -mtime +$RETENTION_DAYS -exec rm -f {} \; \
|
||||
-exec echo "$UUID deleted: {}" \;
|
||||
done
|
||||
|
||||
done
|
||||
@@ -0,0 +1,22 @@
|
||||
#!/sbin/openrc-run
|
||||
|
||||
name="rotateLogs"
|
||||
description="Daily Odoo log rotation"
|
||||
|
||||
pidfile="/run/${RC_SVCNAME}.pid"
|
||||
output_log="/4server/data/log/rotateLogs.log"
|
||||
error_log="/4server/data/log/rotateLogs.log"
|
||||
|
||||
command="/4server/sbin/rotateLogs"
|
||||
command_background="yes"
|
||||
|
||||
stop() {
|
||||
ebegin "Stopping rotateLogs"
|
||||
start-stop-daemon --stop --pidfile "$pidfile"
|
||||
eend $?
|
||||
}
|
||||
|
||||
depend() {
|
||||
need localmount
|
||||
after bootmisc
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
listen_addresses = '*'
|
||||
max_connections = 150
|
||||
dynamic_shared_memory_type = posix
|
||||
max_wal_size = 1GB
|
||||
min_wal_size = 80MB
|
||||
log_timezone = 'Etc/UTC'
|
||||
datestyle = 'iso, mdy'
|
||||
timezone = 'Etc/UTC'
|
||||
lc_messages = 'en_US.utf8'
|
||||
lc_monetary = 'en_US.utf8'
|
||||
lc_numeric = 'en_US.utf8'
|
||||
lc_time = 'en_US.utf8'
|
||||
default_text_search_config = 'pg_catalog.english'
|
||||
shared_buffers = 2GB
|
||||
effective_cache_size = 10GB
|
||||
effective_io_concurrency = 100
|
||||
random_page_cost = 2
|
||||
@@ -68,6 +68,13 @@ rex doas chown root:root /etc/init.d/cleanTmp
|
||||
rex doas rc-update add cleanTmp default
|
||||
rex doas rc-service cleanTmp restart
|
||||
|
||||
#INSTALL rotateLogs SERVICE
|
||||
template templates/init.d/rotateLogs /etc/init.d/rotateLogs
|
||||
rex doas chmod 0755 /etc/init.d/rotateLogs
|
||||
rex doas chown root:root /etc/init.d/rotateLogs
|
||||
rex doas rc-update add rotateLogs default
|
||||
rex doas rc-service rotateLogs restart
|
||||
|
||||
#INSTALL cpu service
|
||||
template templates/init.d/cpu /etc/init.d/cpu
|
||||
rex doas chmod 0755 /etc/init.d/cpu
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
echo "Running prsync ./sbin"
|
||||
prsync -h "/app/host_vars/hosts" -avz ./sbin/ /4server/sbin/
|
||||
template templates/.profile /home/4server/.profile
|
||||
template templates/postgresql.conf /4server/data/postgres/data/postgresql.conf
|
||||
|
||||
rex doas rc-service api restart
|
||||
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user