ci: cron-агрегатор внешних RSS (scripts/package.json + install-cron.sh)
All checks were successful
deploy / deploy (push) Successful in 48s
All checks were successful
deploy / deploy (push) Successful in 48s
- Изолированный scripts/package.json с одним fast-xml-parser, чтобы не раздувать root node_modules на хосте - scripts/install-cron.sh — настройка cron /etc/cron.d/pushkino-rss-aggregator, hourly /usr/bin/node pull-external-rss.mjs → data/news.json - logrotate weekly × 4 для /var/log/pushkino-rss-aggregator.log - Bind-mount data/ уже подцеплен в docker-compose как /var/lib/pushkino/data:ro
This commit is contained in:
@@ -22,7 +22,6 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/sanitize-html": "^2.16.0",
|
"@types/sanitize-html": "^2.16.0",
|
||||||
"fast-xml-parser": "^4.5.0",
|
|
||||||
"sharp": "^0.34.5"
|
"sharp": "^0.34.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
42
scripts/install-cron.sh
Normal file
42
scripts/install-cron.sh
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Установка cron-агрегатора внешних RSS на web.hhivp.com.
|
||||||
|
# Запуск: sudo bash scripts/install-cron.sh
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
DEPLOY_PATH="${DEPLOY_PATH:-/opt/docker/sites/pushkinohistory-ru-v2}"
|
||||||
|
DATA_DIR="$DEPLOY_PATH/data"
|
||||||
|
CRON_FILE="/etc/cron.d/pushkino-rss-aggregator"
|
||||||
|
LOG_FILE="/var/log/pushkino-rss-aggregator.log"
|
||||||
|
|
||||||
|
cd "$DEPLOY_PATH/scripts"
|
||||||
|
echo "==> installing fast-xml-parser into $DEPLOY_PATH/scripts/node_modules"
|
||||||
|
sudo -u striker npm install --no-audit --no-fund --omit=dev 2>&1 | tail -3
|
||||||
|
|
||||||
|
mkdir -p "$DATA_DIR"
|
||||||
|
chown striker:docker "$DATA_DIR"
|
||||||
|
chmod 775 "$DATA_DIR"
|
||||||
|
|
||||||
|
cat > "$CRON_FILE" <<EOF
|
||||||
|
# Pulls external RSS feeds → $DATA_DIR/news.json
|
||||||
|
# Bind-mounted в контейнер pushkinohistory-ru-v2 как /var/lib/pushkino/data:ro
|
||||||
|
SHELL=/bin/bash
|
||||||
|
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||||
|
# каждый час в 12-ю минуту
|
||||||
|
12 * * * * striker cd $DEPLOY_PATH && /usr/bin/node scripts/pull-external-rss.mjs >> $LOG_FILE 2>&1
|
||||||
|
EOF
|
||||||
|
chmod 644 "$CRON_FILE"
|
||||||
|
|
||||||
|
cat > /etc/logrotate.d/pushkino-rss-aggregator <<EOF
|
||||||
|
$LOG_FILE {
|
||||||
|
weekly
|
||||||
|
rotate 4
|
||||||
|
compress
|
||||||
|
delaycompress
|
||||||
|
missingok
|
||||||
|
notifempty
|
||||||
|
copytruncate
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
systemctl reload cron
|
||||||
|
echo "==> done. cron file: $CRON_FILE | log: $LOG_FILE"
|
||||||
9
scripts/package.json
Normal file
9
scripts/package.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"name": "pushkinohistory-cron",
|
||||||
|
"type": "module",
|
||||||
|
"private": true,
|
||||||
|
"description": "Standalone cron-скрипт для агрегации внешних RSS. Изолирован от основного app package.json.",
|
||||||
|
"dependencies": {
|
||||||
|
"fast-xml-parser": "^4.5.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user