Skip to content

log chain initialization to file#254

Open
wanwiset25 wants to merge 2 commits intomasterfrom
init-logging
Open

log chain initialization to file#254
wanwiset25 wants to merge 2 commits intomasterfrom
init-logging

Conversation

@wanwiset25
Copy link
Copy Markdown
Collaborator

@wanwiset25 wanwiset25 commented Mar 30, 2026

Summary by CodeRabbit

  • Chores
    • Improved startup scripts for devnet, mainnet, and testnet: initialization output is now captured to log files for easier troubleshooting and monitoring, and scripts will explicitly stop if the initialization step fails.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 30, 2026

📝 Walkthrough

Walkthrough

Three deployment scripts (devnet, mainnet, testnet) reorder the XDC CLI so --datadir appears before init, pipe combined stdout/stderr through tee /work/xdcchain/init.log, and capture the XDC process exit code via PIPESTATUS[0], exiting with that code on failure.

Changes

Cohort / File(s) Summary
XDC Initialization Command Updates
devnet/start.sh, mainnet/start-node.sh, testnet/start-apothem.sh
Moved --datadir before the init subcommand, added `2>&1

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I hopped through scripts at break of dawn,
Moved flags and logged the seeds I’d sown,
Tee caught the chatter, kept a cozy log,
PIPESTATUS told me when to stop the jog,
Genesis sprouts safe in a snug little bog. 🌱

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'log chain initialization to file' accurately reflects the main change: adding logging of XDC initialization to a file via tee redirection across all three shell scripts.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch init-logging

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
mainnet/start-node.sh (1)

12-17: Also handle tee failures so init logging is guaranteed.

At Line 12, a log-write failure can be missed because only PIPESTATUS[0] is checked. If init.log is operationally required, fail when PIPESTATUS[1] is non-zero too.

Suggested patch
-    XDC --datadir /work/xdcchain init /work/genesis.json 2>&1 | tee /work/xdcchain/init.log
-    init_status=${PIPESTATUS[0]}
-    if [ "$init_status" -ne 0 ]
-    then
-      exit "$init_status"
-    fi
+    XDC --datadir /work/xdcchain init /work/genesis.json 2>&1 | tee /work/xdcchain/init.log
+    init_status=${PIPESTATUS[0]}
+    tee_status=${PIPESTATUS[1]}
+    if [ "$init_status" -ne 0 ]; then
+      exit "$init_status"
+    fi
+    if [ "$tee_status" -ne 0 ]; then
+      exit "$tee_status"
+    fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@mainnet/start-node.sh` around lines 12 - 17, The current init command only
checks init_status from PIPESTATUS[0] and ignores tee failures; update the
post-command check to also examine PIPESTATUS[1] (the tee process) and fail if
either PIPESTATUS[0] or PIPESTATUS[1] is non-zero—e.g., capture both statuses
after running "XDC --datadir ... init /work/genesis.json 2>&1 | tee
/work/xdcchain/init.log", set a combined exit condition using init_status and
tee_status (or check each separately) and call exit with a non-zero code when
PIPESTATUS[1] indicates tee failed so that init.log write errors cannot be
silently ignored.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@mainnet/start-node.sh`:
- Around line 12-17: The current init command only checks init_status from
PIPESTATUS[0] and ignores tee failures; update the post-command check to also
examine PIPESTATUS[1] (the tee process) and fail if either PIPESTATUS[0] or
PIPESTATUS[1] is non-zero—e.g., capture both statuses after running "XDC
--datadir ... init /work/genesis.json 2>&1 | tee /work/xdcchain/init.log", set a
combined exit condition using init_status and tee_status (or check each
separately) and call exit with a non-zero code when PIPESTATUS[1] indicates tee
failed so that init.log write errors cannot be silently ignored.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c30b5584-ce8b-4b2e-848f-841e1c6d2a26

📥 Commits

Reviewing files that changed from the base of the PR and between cd2c8ae and 5780db6.

📒 Files selected for processing (3)
  • devnet/start.sh
  • mainnet/start-node.sh
  • testnet/start-apothem.sh
🚧 Files skipped from review as they are similar to previous changes (2)
  • devnet/start.sh
  • testnet/start-apothem.sh

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants