Compare commits
6
Commits
48601ee943
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d3d9614825 | ||
|
|
3acdc81891 | ||
|
|
dcaaf46ef3 | ||
|
|
c8111645e4 | ||
|
|
729b24edd8 | ||
|
|
8a1bc3cba2 |
+1
-1
@@ -501,7 +501,7 @@ async def get_odoo_log_summary(uuid: str):
|
|||||||
# --- Main logic ---
|
# --- Main logic ---
|
||||||
try:
|
try:
|
||||||
# Last 500 lines from Odoo log
|
# 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 = [
|
important_odoo_lines = [
|
||||||
line for line in last_500_lines if is_important_line(line)
|
line for line in last_500_lines if is_important_line(line)
|
||||||
]
|
]
|
||||||
|
|||||||
+24
-3
@@ -1,8 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# checkFilestore <UUID> — compare container filestore vs host disk via md5
|
# checkFilestore <UUID> — compare container filestore vs host disk via md5
|
||||||
|
|
||||||
[[ -z "${1-}" ]] && { echo "Usage: $0 <UUID>"; exit 1; }
|
check_one() {
|
||||||
UUID="$1"
|
local UUID="$1"
|
||||||
|
|
||||||
FILESTORE_HOST="/4server/data/$UUID/odoo/odoo-web-data/filestore/$UUID"
|
FILESTORE_HOST="/4server/data/$UUID/odoo/odoo-web-data/filestore/$UUID"
|
||||||
|
|
||||||
@@ -34,4 +34,25 @@ MD5_HOST=$(find "$FILESTORE_HOST" -type f | sort | xargs md5sum 2>/dev/null | aw
|
|||||||
echo "Container : $MD5_CONTAINER"
|
echo "Container : $MD5_CONTAINER"
|
||||||
echo "Host : $MD5_HOST"
|
echo "Host : $MD5_HOST"
|
||||||
|
|
||||||
[[ "$MD5_CONTAINER" == "$MD5_HOST" ]] && echo "OK: filestores match" || { echo "FAIL: mismatch"; exit 3; }
|
[[ "$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-update add cleanTmp default
|
||||||
rex doas rc-service cleanTmp restart
|
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
|
#INSTALL cpu service
|
||||||
template templates/init.d/cpu /etc/init.d/cpu
|
template templates/init.d/cpu /etc/init.d/cpu
|
||||||
rex doas chmod 0755 /etc/init.d/cpu
|
rex doas chmod 0755 /etc/init.d/cpu
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
echo "Running prsync ./sbin"
|
echo "Running prsync ./sbin"
|
||||||
prsync -h "/app/host_vars/hosts" -avz ./sbin/ /4server/sbin/
|
prsync -h "/app/host_vars/hosts" -avz ./sbin/ /4server/sbin/
|
||||||
template templates/.profile /home/4server/.profile
|
template templates/.profile /home/4server/.profile
|
||||||
|
template templates/postgresql.conf /4server/data/postgres/data/postgresql.conf
|
||||||
|
|
||||||
rex doas rc-service api restart
|
rex doas rc-service api restart
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user