Skip to content

Revert "Claude/update prod runner script lq2g s (#62)" - #63

Closed
gamblecodezcom wants to merge 1 commit into
mainfrom
revert-62-claude/update-prod-runner-script-Lq2gS
Closed

Revert "Claude/update prod runner script lq2g s (#62)"#63
gamblecodezcom wants to merge 1 commit into
mainfrom
revert-62-claude/update-prod-runner-script-Lq2gS

Conversation

@gamblecodezcom

@gamblecodezcom gamblecodezcom commented Feb 23, 2026

Copy link
Copy Markdown
Owner

User description

This reverts commit 5168fb7.


CodeAnt-AI Description

Use git pull for automated deploys and avoid stopping the service beforehand

What Changed

  • The bot and the prod-run script now update code with git pull (instead of fetch + hard reset), so deployments attempt a normal pull/merge rather than forcibly resetting the working tree
  • The deploy.sh script no longer stops the systemd service before updating and no longer runs git clean -fd in the pull step
  • Deployment status messages were updated to reflect the git pull outcome

Impact

✅ Shorter deploy downtime
✅ Preserves local untracked files during deploy
✅ Avoids forcibly discarding local changes when using bot/prod-run

💡 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 23, 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.

@gamblecodezcom

Copy link
Copy Markdown
Owner Author

Accidentally hit revert

@codeant-ai codeant-ai Bot added the size:S This PR changes 10-29 lines, ignoring generated files label Feb 23, 2026
@codeant-ai

codeant-ai Bot commented Feb 23, 2026

Copy link
Copy Markdown

Nitpicks 🔍

🔒 No security issues identified
⚡ Recommended areas for review

  • Potential Race Condition
    The deploy script no longer stops the running service before performing a hard git reset. Resetting files while the service is running can cause file locks, partial updates, or runtime inconsistencies. Consider stopping the service before modifying files or otherwise ensuring an atomic update.

  • Non-deterministic git update
    The runner now uses git pull which can create merge commits, block on local changes, or leave the working tree in a different state than a deterministic fetch+reset. The previous approach was fetch+reset (and clean) which guarantees the exact remote state. Consider using fetch+reset or at least git pull --ff-only plus a cleanup step to avoid unexpected merges.

  • Untracked Files Retained
    The previous version ran git clean -fd after reset to remove stray/untracked files. That step was removed, so untracked files left on disk may persist across deployments and lead to surprising behavior. Confirm whether this was intentional; if not, reintroduce a targeted cleanup step.

Comment thread prod-run.sh
Comment on lines +43 to +47
say "Pulling latest code from origin main..."
if git -C "$PROJECT_DIR" pull origin main 2>&1; then
say "Git pull successful"
else
warn "Git fetch/reset failed — continuing with local copy"
warn "Git pull failed — continuing with local copy"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Using git pull in this unattended script means that if the remote main branch diverges and a merge conflict occurs, the command will leave the working tree in a conflicted/partially-updated state but the script only logs a warning and continues to restart the service, so the app may run with broken files containing merge markers. A safer pattern is to use git fetch plus git reset --hard origin/main (like the deploy script) and abort on failure so the service never runs against a conflicted tree. [logic error]

Severity Level: Major ⚠️
- ❌ prod-run.sh may restart bot with conflicted source files.
- ❌ Telegram bot downtime if Node fails to start.
- ⚠️ /health and /metrics endpoints unavailable during failure. 
- ⚠️ Divergent prod repo state harder to recover reliably.
Suggested change
say "Pulling latest code from origin main..."
if git -C "$PROJECT_DIR" pull origin main 2>&1; then
say "Git pull successful"
else
warn "Git fetch/reset failed — continuing with local copy"
warn "Git pull failed — continuing with local copy"
say "Pulling latest code from origin/main..."
if git -C "$PROJECT_DIR" fetch origin main 2>&1 && \
git -C "$PROJECT_DIR" reset --hard origin/main 2>&1; then
say "Git update successful"
else
err "Git update failed — aborting to avoid running with a conflicted or partial checkout"
exit 1
Steps of Reproduction ✅
1. On the production host, ensure the bot is deployed under `/var/www/html/Runewager` as
described in `README.md:102-124`, and that `prod-run.sh` is present (verified at
`/workspace/Runewager/prod-run.sh:1-365`).

2. From the project directory, create a local change that will conflict with an upcoming
remote change (e.g., edit `index.js` and commit it locally), so the local branch diverges
from `origin/main` while still using the same repo (any normal git workflow on this
directory, since `prod-run.sh` uses `$PROJECT_DIR` as resolved at `prod-run.sh:16-23`).

3. Push a conflicting change to `origin/main` from another environment so that a
subsequent `git pull origin main` from the server will produce merge conflicts (standard
git behavior when local and remote modify overlapping sections).

4. On the server, run `npm run prod` (entrypoint defined in `package.json:10-13` as
`./prod-run.sh`) or execute `./prod-run.sh` directly; when `prod-run.sh` reaches the block
at `prod-run.sh:43-48`, `git -C "$PROJECT_DIR" pull origin main` attempts the merge, fails
with conflicts, returns non-zero, and leaves the working tree with conflict markers, but
because the command is used in an `if ... then` test (exempt from `set -e` at
`prod-run.sh:9`), the script only logs `warn "Git pull failed — continuing with local
copy"` and continues into the restart logic at `prod-run.sh:313-340`, attempting to
restart `node index.js` against a conflicted/partially-updated tree, which can cause
runtime syntax errors or a failed start.
Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** prod-run.sh
**Line:** 43:47
**Comment:**
	*Logic Error: Using `git pull` in this unattended script means that if the remote `main` branch diverges and a merge conflict occurs, the command will leave the working tree in a conflicted/partially-updated state but the script only logs a warning and continues to restart the service, so the app may run with broken files containing merge markers. A safer pattern is to use `git fetch` plus `git reset --hard origin/main` (like the deploy script) and abort on failure so the service never runs against a conflicted tree.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
👍 | 👎

@codeant-ai

codeant-ai Bot commented Feb 23, 2026

Copy link
Copy Markdown

CodeAnt AI finished reviewing your PR.

@gamblecodezcom
gamblecodezcom deleted the revert-62-claude/update-prod-runner-script-Lq2gS branch February 23, 2026 01:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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