Skip to content

Fix prod-run.sh path logic for node_modules, logrotate, and systemd templates - #47

Merged
gamblecodezcom merged 1 commit into
mainfrom
codex/main
Feb 21, 2026
Merged

Fix prod-run.sh path logic for node_modules, logrotate, and systemd templates#47
gamblecodezcom merged 1 commit into
mainfrom
codex/main

Conversation

@gamblecodezcom

@gamblecodezcom gamblecodezcom commented Feb 21, 2026

Copy link
Copy Markdown
Owner

User description

Motivation

  • Address review-reported logic bugs that break VPS deployments: unnecessary dependency reinstalls, and hard-coded /var/www/html/Runewager paths in generated logrotate and systemd unit files.
  • Make the launcher resilient and portable so generated operational configs reflect the actual PROJECT_DIR and LOG_DIR used at runtime.

Description

  • Replace the non-standard sentinel check in fix_node_modules: only install when node_modules is missing and use npm ci --omit=dev if package-lock.json exists or fall back to npm install --omit=dev otherwise.
  • Update ensure_logrotate_config to generate a template that uses $LOG_DIR instead of /var/www/html/Runewager and add logic to replace an existing /etc/logrotate.d/runewager when it doesn't reference the detected $LOG_DIR.
  • Update ensure_systemd_service to emit a unit that uses $PROJECT_DIR and $LOG_DIR for WorkingDirectory, ExecStart, EnvironmentFile, and StandardOutput, and expand required-directive checks so stale hard-coded units get corrected.
  • Keep existing validation steps (dry-run logrotate validation and systemctl daemon-reload) so automated checks still run after fixes.

Testing

  • Ran shell syntax check with bash -n prod-run.sh; syntax validation passed.
  • Verified changes via git diff -- prod-run.sh and committed the patch; commit message: Fix prod-run path handling for deps, logrotate, and systemd.
  • Confirmed the script still performs its existing logrotate dry-run and systemctl daemon-reload calls for runtime validation (no failures introduced by edits).

Codex Task

Summary by CodeRabbit

  • Bug Fixes

    • Improved dependency installation logic to avoid unnecessary reinstalls and enhance efficiency.
  • Chores

    • Updated log rotation configuration for better log management and organization.
    • Enhanced systemd service configuration with improved directory path handling.
    • Refined environment and path references for system consistency.

CodeAnt-AI Description

Fix prod-run behavior: avoid redundant npm reinstalls and make logrotate/systemd use actual project and log directories

What Changed

  • Only install Node dependencies when node_modules is missing; use "npm ci" if package-lock.json exists, otherwise fall back to "npm install"
  • Generated logrotate config now points to the detected log directory and will replace an existing logrotate file if it doesn't reference that directory; still runs a dry-run validation
  • Generated systemd unit now uses the detected project and log directories for WorkingDirectory, ExecStart, EnvironmentFile, and StandardOutput, and will correct stale units that contain hard-coded paths

Impact

✅ Fewer unnecessary dependency reinstalls
✅ Correct log rotation for actual log location
✅ Systemd service runs with correct project and log paths

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

@codeant-ai

codeant-ai Bot commented Feb 21, 2026

Copy link
Copy Markdown

CodeAnt AI is reviewing your PR.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Feb 21, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This change refactors the prod-run.sh deployment script to improve node module installation logic and standardize directory path references. The fix_node_modules function now conditionally uses npm ci or npm install based on package-lock.json availability. The ensure_logrotate_config and ensure_systemd_service functions are updated to use new directory variables ($PROJECT_DIR, $LOG_DIR) for configuration paths.

Changes

Cohort / File(s) Summary
Node Module Installation
prod-run.sh
Rework fix_node_modules logic to install only when node_modules is missing. Use npm ci \--omit=dev if package-lock.json exists, otherwise fall back to npm install \--omit=dev with a warning message.
Log Rotation Configuration
prod-run.sh
Update ensure_logrotate_config to reference new $LOG_DIR variable for runewager and crash logs. Add logic to replace the logrotate file if it does not reference the detected log directory.
Systemd Service Configuration
prod-run.sh
Update ensure_systemd_service to use $PROJECT_DIR for WorkingDirectory and ExecStart, $PROJECT_DIR/.env for EnvironmentFile, and $LOG_DIR/runewager-1.log for StandardOutput. Adjust public directives array to reflect new paths.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 Paths align with variables so clean,
node_modules installing between,
logrotate spins, systemd takes care,
configuration blooms fresh in the air! 🌱


Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Comment @coderabbitai help to get the list of available commands and usage tips.

@gamblecodezcom
gamblecodezcom merged commit 9310cd2 into main Feb 21, 2026
1 of 2 checks passed
@gamblecodezcom
gamblecodezcom deleted the codex/main branch February 21, 2026 00:55
@codeant-ai codeant-ai Bot added the size:S This PR changes 10-29 lines, ignoring generated files label Feb 21, 2026
@codeant-ai

codeant-ai Bot commented Feb 21, 2026

Copy link
Copy Markdown

Nitpicks 🔍

🔒 No security issues identified
⚡ Recommended areas for review

  • Systemd directive matching strictness
    The required-directive check uses exact-line matching (grep -Fqx) which fails if directives differ in spacing, ordering, or use slight variants. That could cause unexpected replacements or misses. Also ensure writing to /etc/systemd/system is done atomically and consider validating EnvironmentFile presence before pointing to it in the unit.

  • Dependency install context
    The new logic runs npm ci/npm install when node_modules is missing, but the commands rely on the current working directory to be PROJECT_DIR. If fix_working_directory is not run (or fails) prior to fix_node_modules, npm may run in the wrong directory or fail when package.json is missing. Consider making the npm invocations explicitly target PROJECT_DIR and guarding against missing package.json.

  • Logrotate detection fragility
    The check that decides whether to replace /etc/logrotate.d/runewager uses a fixed-string grep of the literal glob "$LOG_DIR/runewager*.log". This may miss valid existing configs that reference the directory with different patterns, whitespace differences, or use explicit filenames. It can cause unnecessary overwrites or fail to update stale configs. Consider a more flexible detection (regex or checking for $LOG_DIR presence) before replacing.

@codeant-ai

codeant-ai Bot commented Feb 21, 2026

Copy link
Copy Markdown

CodeAnt AI finished reviewing your PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex size:S This PR changes 10-29 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant