feat(cli): configure logrotate during migration#1927
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds an EasyEngine-managed logrotate setup step to the CLI migration flow, aiming to ensure EasyEngine/site/nginx-proxy logs are rotated on Linux hosts so they don’t grow without bounds.
Changes:
- Registers a new final migration step (
ee-setup-logrotate) inRunner::migrate(). - Introduces
EE\Logrotate\Utils::setup_logrotate()to write logrotate configs under/etc/logrotate.d. - Adds validation and one-time forced rotation logic, plus cleanup of legacy per-site/per-proxy configs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| php/EE/Runner.php | Adds a migration step to run logrotate setup during CLI migration. |
| php/EE/Logrotate/Utils.php | New utility to install (if possible), write, validate, force-run, and cleanup logrotate configs for EE-managed logs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
Tested PR PHAR on test server ee-cli-testing-aws.rt.gw. Built PHAR locally: php -dphar.readonly=0 utils/make-phar.php easyengine.phar --version=4.11.0-nightly-pr1927
php easyengine.phar cli version
ls -lh easyengine.pharOutput: Copied PHAR to test server: scp -i ~/.ssh/rtcamp_key -o IdentitiesOnly=yes \
easyengine.phar \
root@65.1.186.151:/root/easyengine-pr1927.pharOutput: Checked PHAR on server: lsOutput: Replaced set -euo pipefail
echo "== before =="
which ee
ee cli version
ee site list
cp -av "$(command -v ee)" "/root/ee.backup.$(date +%Y%m%d%H%M%S)"
install -m 0755 /root/easyengine-pr1927.phar "$(command -v ee)"
hash -r
echo "== after PR PHAR =="
which ee
ee cli version
ee site listOutput: Checked existing sites and logrotate dry-run: echo "== existing sites =="
ee site info ab-ee-test1.rt.gw
ee site info ab-ee-test2.rt.gw
echo "== logrotate files =="
ls -l /etc/logrotate.d/ee* 2>/dev/null || true
echo "== logrotate configs + dry-run =="
for f in /etc/logrotate.d/ee*; do
echo "===== $f ====="
sed -n '1,160p' "$f"
echo "----- dry-run -----"
logrotate -d "$f" 2>&1 | tail -40
doneOutput summary: Created a new WP site with the PR PHAR: ee site create ab-ee-test3.rt.gw --type=wp --skip-status-check
ee site info ab-ee-test3.rt.gw
ee site list
echo "== logrotate files after new site =="
ls -l /etc/logrotate.d/ee* 2>/dev/null || trueOutput: Final verification: ee cli version
ls -l /etc/logrotate.d/ee*
logrotate -d /etc/logrotate.d/ee_sites 2>&1 | tail -60Output: Result: PHAR validation passed on existing setup and new site setup. |
Summary
Adds EasyEngine-managed log rotation setup during CLI migration so site, nginx-proxy, and EasyEngine CLI logs do not grow unbounded on Ubuntu/Linux servers.
The migration now writes and validates logrotate configs for:
EE_ROOT_DIR/logs/*.logEE_ROOT_DIR/sites/*/logs/nginx/*.logEE_ROOT_DIR/sites/*/logs/php/*.logEE_ROOT_DIR/services/nginx-proxy/logs/*.logIt also force-rotates these logs once after setup/update, then relies on the system logrotate schedule for daily rotation.
Details
EE\Logrotate\Utils::setup_logrotate().ee-setup-logrotateas the final migration step inRunner::migrate().logrotateviaapt-getif missing and available.copytruncateto avoid per-site container signaling.logrotate -d.logrotate -fonce after successful setup/update.Testing
php -l php/EE/Logrotate/Utils.phpphp -l php/EE/Runner.phpgit diff --check origin/develop...HEADEE\Logrotate\Utilslogrotate -dlogrotate -f