-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
switch index to esm and add ecosystem.config.js
- Loading branch information
1 parent
470d322
commit 1332efd
Showing
8 changed files
with
189 additions
and
280 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
const { GROUP, NODE_ENV } = require('./config.js'); | ||
|
||
let arr = [ | ||
{ | ||
"name": "web", | ||
"script": "svc/web.mjs", | ||
"group": "web", | ||
}, | ||
{ | ||
"name": "retriever", | ||
"script": "svc/retriever.mjs", | ||
"group": "retriever", | ||
}, | ||
{ | ||
"name": "proxy", | ||
"script": "svc/proxy.mjs", | ||
"group": "proxy", | ||
}, | ||
{ | ||
"name": "parser", | ||
"script": "svc/parser.mjs", | ||
}, | ||
{ | ||
"name": "apiadmin", | ||
"script": "svc/apiadmin.mjs", | ||
"group": "backend", | ||
}, | ||
{ | ||
"name": "mmr", | ||
"script": "svc/mmr.mjs", | ||
"group": "backend", | ||
}, | ||
{ | ||
"name": "profiler", | ||
"script": "svc/profiler.mjs", | ||
"group": "backend", | ||
}, | ||
{ | ||
"name": "scanner", | ||
"script": "svc/scanner.mjs", | ||
"group": "backend", | ||
}, | ||
{ | ||
"name": "fullhistory", | ||
"script": "svc/fullhistory.mjs", | ||
"group": "backend", | ||
}, | ||
{ | ||
"name": "fullhistory", | ||
"script": "svc/autofullhistory.mjs", | ||
"group": "backend", | ||
}, | ||
{ | ||
"name": "monitor", | ||
"script": "svc/monitor.mjs", | ||
"group": "backend", | ||
}, | ||
{ | ||
"name": "gcdata", | ||
"script": "svc/gcdata.mjs", | ||
"group": "backend", | ||
}, | ||
{ | ||
"name": "buildsets", | ||
"script": "svc/buildsets.mjs", | ||
"group": "backend", | ||
}, | ||
{ | ||
"name": "cosmetics", | ||
"script": "svc/cosmetics.mjs", | ||
"group": "backend", | ||
}, | ||
{ | ||
"name": "distributions", | ||
"script": "svc/distributions.mjs", | ||
"group": "backend", | ||
}, | ||
{ | ||
"name": "heroes", | ||
"script": "svc/heroes.mjs", | ||
"group": "backend", | ||
}, | ||
{ | ||
"name": "herostats", | ||
"script": "svc/herostats.mjs", | ||
"group": "backend", | ||
}, | ||
{ | ||
"name": "items", | ||
"script": "svc/items.mjs", | ||
"group": "backend", | ||
}, | ||
{ | ||
"name": "leagues", | ||
"script": "svc/leagues.mjs", | ||
"group": "backend", | ||
}, | ||
{ | ||
"name": "livegames", | ||
"script": "svc/livegames.mjs", | ||
"group": "backend", | ||
}, | ||
{ | ||
"name": "proplayers", | ||
"script": "svc/proplayers.mjs", | ||
"group": "backend", | ||
}, | ||
{ | ||
"name": "teams", | ||
"script": "svc/teams.mjs", | ||
"group": "backend", | ||
}, | ||
{ | ||
"name": "scenarios", | ||
"script": "svc/scenarios.mjs", | ||
"group": "backend", | ||
}, | ||
{ | ||
"name": "scenariosCleanup", | ||
"script": "svc/scenariosCleanup.mjs", | ||
"group": "backend", | ||
}, | ||
{ | ||
"name": "counts", | ||
"script": "svc/counts.mjs", | ||
"group": "backend", | ||
}, | ||
{ | ||
"name": "syncSubs", | ||
"script": "svc/syncSubs.mjs", | ||
"group": "backend", | ||
}, | ||
{ | ||
"name": "cassandraDelete", | ||
"script": "svc/cassandraDelete.mjs", | ||
"group": "backend", | ||
} | ||
]; | ||
|
||
// If GROUP is set filter to only the matching group | ||
arr = arr.filter(app => !GROUP || app.group === GROUP); | ||
|
||
const apps = arr.map(app => { | ||
const dev = NODE_ENV === 'development'; | ||
return { | ||
...app, | ||
watch: dev ? true : false, | ||
ignore_watch: [".git", "node_modules"], | ||
exec_mode: 'fork', | ||
instances: 1, | ||
} | ||
}); | ||
|
||
module.exports = { | ||
apps | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* Entry point for the application. | ||
* */ | ||
import cp from 'child_process'; | ||
if (process.env.PROVIDER === 'gce') { | ||
cp.execSync( | ||
'curl -H "Metadata-Flavor: Google" -L http://metadata.google.internal/computeMetadata/v1/project/attributes/env > /usr/src/.env' | ||
); | ||
} | ||
// Do this after the metadata download since it uses config | ||
const ecosystem = await import('./ecosystem.config.js'); | ||
if (process.env.ROLE) { | ||
// if role variable is set just run that script | ||
const app = ecosystem.apps.find((app) => app.name === process.env.ROLE); | ||
import('./' + app.script); | ||
} else if (process.env.GROUP) { | ||
// or run the group with pm2 | ||
cp.execSync( | ||
'pm2 start ecosystem.config.js' | ||
); | ||
setInterval(() => { | ||
cp.execSync('pm2 flush all'); | ||
}, 60 * 60 * 1000); | ||
} else { | ||
// Block indefinitely (keep process alive for Docker) | ||
process.stdin.resume(); | ||
} |
Oops, something went wrong.