Skip to content

Make 'up' and 'up-bds' Makefile targets idempotent#402

Merged
Endogen merged 1 commit intoxian-network:mainnetfrom
Endogen:fix-pm2-duplicates
Feb 1, 2026
Merged

Make 'up' and 'up-bds' Makefile targets idempotent#402
Endogen merged 1 commit intoxian-network:mainnetfrom
Endogen:fix-pm2-duplicates

Conversation

@Endogen
Copy link
Copy Markdown
Contributor

@Endogen Endogen commented Feb 1, 2026

Problem

Running make up multiple times creates duplicate pm2 processes because the -f (force) flag always starts new processes even when ones with the same name already exist.

This leads to:

  • Database lock errors: failed to create node: failed to initialize database: resource temporarily unavailable
  • Resource waste: Multiple xian/cometbft processes running simultaneously
  • Confusing pm2 output: Processes with the same name but different IDs

Example of the issue:

│ id │ name     │ status  │
├────┼──────────┼─────────┤
│ 1  │ xian     │ online  │
│ 2  │ cometbft │ online  │
│ 3  │ xian     │ online  │  ← duplicate
│ 4  │ cometbft │ errored │  ← duplicate, failed due to db lock

Solution

Delete existing processes before starting new ones:

up:
	@pm2 delete xian 2>/dev/null || true
	@pm2 delete cometbft 2>/dev/null || true
	cd ./src/xian && pm2 start xian_abci.py --name xian
	pm2 start "../cometbft node --rpc.laddr tcp://0.0.0.0:26657" --name cometbft
  • The || true ensures no error on first run when processes don't exist yet
  • Removed -f flag since we're now ensuring a clean state
  • Same fix applied to up-bds target

Testing

Tested locally - running make up multiple times no longer creates duplicates.

Previously, running 'make up' multiple times would create duplicate pm2
processes because the -f (force) flag always starts new processes even
if ones with the same name already exist.

This led to errors like:
- 'resource temporarily unavailable' (database locks from duplicate cometbft)
- Multiple xian/cometbft processes consuming resources

Fix: Delete existing processes before starting new ones, and remove the
-f flag since we're now ensuring a clean state.

The delete commands use '|| true' to avoid errors on first run when no
processes exist yet.
@Endogen Endogen merged commit dc686e3 into xian-network:mainnet Feb 1, 2026
1 check passed
@Endogen Endogen deleted the fix-pm2-duplicates branch February 1, 2026 22:27
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.

1 participant