CosmicAC PM2 Configuration
Configure the PM2 ecosystem file, automatic app-node secrets generation, and HRPC keypair generation for CosmicAC workers.
CosmicAC PM2 Configuration
Copy PM2 Folder (Manual Step)
TODO: The pm2/ folder (containing stg.ecosystem.config.js, dev.ecosystem.config.js, and package.json) is not part of any of the six cloned repositories. Obtain it from your team's internal shared location or artifact store.
Copy the entire pm2 folder to the home directory:
# Copy the pm2 folder with ecosystem configs
cp -r /path/to/pm2 ~/Note: The autobase-connect.js script is created manually in the Autobase Connection guide.
Install PM2 Dependencies
cd ~/pm2
npm installThis installs hypercore-crypto which is needed for automatic HRPC keypair generation.
Ecosystem Configuration Reference
The stg.ecosystem.config.js file manages all worker processes. Here's the component configuration:
| Component | PM2 Name Pattern | Default Port | Worker Type / Command |
|---|---|---|---|
| wrk-ork | wrk-ork-{i} | - | wrk-ork-proc-aggr |
| app-node | app-node-{i} | 3000 | wrk-node-http |
| wrk-server-k8s-nvidia | wrk-server-k8s-nvidia-{i} | - | wrk-server-rack-k8s |
| proxy-inference | proxy-inference-http-{i} | 8000 | wrk-proxy-http |
| proxy-inference | proxy-inference-hrpc-{i} | - | wrk-proxy-hrpc |
| tether-wrk-ext-sendgrid | wrk-ext-sendgrid | - | wrk-ext-sendgrid |
| cosmicac-ui | app-ui | 5173 | npx serve -s -l 5173 dist |
Note: The UI runs as a static file server using serve package, not as a worker.
Automatic App-Node Secrets Generation
The ecosystem config automatically generates secrets for cosmicac-app-node/config/common.json on first run.
| Secret | Length | Default Value (triggers generation) |
|---|---|---|
| signUpSecret | 16 chars (A-Za-z0-9) | SIGN_UP_SECRET |
| mfaSecretKey | 16 chars (A-Za-z0-9) | MFA_SECRET_KEY |
| apiKeySecret | 64 chars (A-Za-z0-9) | API_KEY_HASHING_SECRET_CHANGE_IN_PRODUCTION |
Secrets are only generated if set to their default placeholder values. Already configured secrets are not overwritten.
Automatic HRPC Keypair Generation
The ecosystem config automatically generates an HRPC keypair for cosmicac-proxy-inference if one doesn't exist.
When PM2 loads the ecosystem config, it checks cosmicac-proxy-inference/config/hrpc.json:
- If
rpcKeypair.secretKeyandrpcKeypair.publicKeyare both empty, it generates a new keypair usinghypercore-crypto - The generated keys are saved back to
hrpc.json - If keys already exist, no changes are made
The hrpc.json file should have this structure:
{
"rpcKeypair": {
"secretKey": "",
"publicKey": ""
}
}After the first PM2 start, it will be populated with the generated keys.