CosmicAC Logo

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 install

This 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:

ComponentPM2 Name PatternDefault PortWorker Type / Command
wrk-orkwrk-ork-{i}-wrk-ork-proc-aggr
app-nodeapp-node-{i}3000wrk-node-http
wrk-server-k8s-nvidiawrk-server-k8s-nvidia-{i}-wrk-server-rack-k8s
proxy-inferenceproxy-inference-http-{i}8000wrk-proxy-http
proxy-inferenceproxy-inference-hrpc-{i}-wrk-proxy-hrpc
tether-wrk-ext-sendgridwrk-ext-sendgrid-wrk-ext-sendgrid
cosmicac-uiapp-ui5173npx 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.

SecretLengthDefault Value (triggers generation)
signUpSecret16 chars (A-Za-z0-9)SIGN_UP_SECRET
mfaSecretKey16 chars (A-Za-z0-9)MFA_SECRET_KEY
apiKeySecret64 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.secretKey and rpcKeypair.publicKey are both empty, it generates a new keypair using hypercore-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.

On this page