diff --git a/.gitignore b/.gitignore index 49eeb9c..cf762de 100644 --- a/.gitignore +++ b/.gitignore @@ -76,4 +76,9 @@ typings/ .serverless # FuseBox cache -.fusebox/src/config/fresh.js +.fusebox/ +src/config/fresh.js + +# PM2 process definition: holds the production DB password in plaintext. +# Use ecosystem.config.example.js as the template. +ecosystem.config.js diff --git a/ecosystem.config.example.js b/ecosystem.config.example.js new file mode 100644 index 0000000..f7617a5 --- /dev/null +++ b/ecosystem.config.example.js @@ -0,0 +1,50 @@ +// PM2 process definition for the production event-source indexer. +// +// Copy this to `ecosystem.config.js` ON THE SERVER and fill in the real values. +// The real file is intentionally NOT tracked: it holds the production database +// password in plaintext. It is also the only copy that exists, so if you change +// it, back it up off-box as well (see "Backups" below). +// +// cp ecosystem.config.example.js ecosystem.config.js +// $EDITOR ecosystem.config.js +// pm2 restart event-source --update-env +// +// Every value below is read by src/config/prod.js straight off process.env, so +// the names here must match that file exactly. +// +// Backups: the live file lives at +// /home/ubuntu/apps/event-source/ecosystem.config.js +// on app.cambiatus.io. Keep a copy somewhere private and chmod 600 — losing it +// means reconstructing the DB credentials by hand. + +module.exports = { + apps: [ + { + name: 'event-source', + time: true, + script: 'src/app.js', + watch: false, + exec_mode: 'fork', + autorestart: true, + env: { + NODE_ENV: 'prod', + + // Chain + BLOCKCHAIN_INIT_BLOCK: '60000000', + BLOCKCHAIN_TOKEN_CONTRACT: 'cambiatus.tk', + BLOCKCHAIN_COMMUNITY_CONTRACT: 'cambiatus.cm', + // Optional: src/config/prod.js defaults it to cambiatus.es when unset. + BLOCKCHAIN_ESCROW_CONTRACT: 'cambiatus.es', + BLOCKCHAIN_URL: 'https://', + + // Database — same Postgres the backend writes to. + DB_USER: '', + DB_PASS: '', + DB_HOST: '', + DB_NAME: '', + + EVENT_SOURCE_HTTP_PORT: 3001 + } + } + ] +}