diff --git a/DEPLOY.md b/DEPLOY.md index ae5a8d6..971a1a9 100644 --- a/DEPLOY.md +++ b/DEPLOY.md @@ -69,7 +69,11 @@ MAXMIND_LICENSE_KEY= 3. Download the database: ```bash +php artisan config:clear php artisan link:geoip-update +php artisan config:cache ``` +On the server, edit **`/var/www/ladill-link/shared/.env`** (not a release copy). After deploy, `current/.env` symlinks to that file. If you add env vars while config is cached, run `config:clear` before `link:geoip-update` or Laravel will not see the new values. + The file is stored at `storage/app/geoip/GeoLite2-Country.mmdb` by default. The command is scheduled weekly via the app scheduler — ensure cron runs `php artisan schedule:run` for link.ladill.com. diff --git a/app/Console/Commands/UpdateGeoIpDatabaseCommand.php b/app/Console/Commands/UpdateGeoIpDatabaseCommand.php index 62a8f20..c113e19 100644 --- a/app/Console/Commands/UpdateGeoIpDatabaseCommand.php +++ b/app/Console/Commands/UpdateGeoIpDatabaseCommand.php @@ -15,11 +15,26 @@ class UpdateGeoIpDatabaseCommand extends Command public function handle(): int { - $accountId = (string) config('link.maxmind_account_id', ''); - $licenseKey = (string) config('link.maxmind_license_key', ''); + $accountId = trim((string) config('link.maxmind_account_id', '')); + $licenseKey = trim((string) config('link.maxmind_license_key', '')); if ($accountId === '' || $licenseKey === '') { - $this->error('Set MAXMIND_ACCOUNT_ID and MAXMIND_LICENSE_KEY in .env before updating GeoIP data.'); + $envPath = realpath(base_path('.env')) ?: base_path('.env'); + $configCached = is_file(base_path('bootstrap/cache/config.php')); + + $this->error('Set MAXMIND_ACCOUNT_ID and MAXMIND_LICENSE_KEY before updating GeoIP data.'); + $this->line(''); + $this->line('Production uses the shared env file (current/.env is usually a symlink):'); + $this->line(' '.$envPath); + $this->line(''); + $this->line('Add both variables there, then refresh config:'); + $this->line(' php artisan config:clear'); + $this->line(' php artisan link:geoip-update'); + $this->line(' php artisan config:cache'); + + if ($configCached) { + $this->warn('Config is cached — Laravel will ignore new .env values until you run config:clear.'); + } return self::FAILURE; } diff --git a/deploy/deploy.sh b/deploy/deploy.sh index 61386df..2a807bf 100755 --- a/deploy/deploy.sh +++ b/deploy/deploy.sh @@ -138,7 +138,7 @@ tar -xzf "$RELEASE_ARCHIVE" -C "$NEW_RELEASE" chmod -R u+rwX "$NEW_RELEASE" 2>/dev/null || true log "Linking shared paths" -mkdir -p "$SHARED_DIR/storage/"{app/public,app/private,framework/{cache/data,sessions,testing,views},logs} +mkdir -p "$SHARED_DIR/storage/"{app/public,app/private,app/geoip,framework/{cache/data,sessions,testing,views},logs} mkdir -p "$SHARED_DIR/bootstrap-cache" normalize_shared_permissions