forked from zellwk/zellwk.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.js
More file actions
23 lines (20 loc) · 735 Bytes
/
start.js
File metadata and controls
23 lines (20 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Overrides existing env with variables from config
// Require this because:
// 1. pm2 cluster mode stores previous env variables
// 2. dotenv doesn't overwrite env variables automatically
// https://www.npmjs.com/package/dotenv
const updateEnv = pathToConfig => {
const envConfig = dotenv.parse(fs.readFileSync(pathToConfig))
for (const k in envConfig) {
process.env[k] = envConfig[k]
}
}
const fs = require('fs')
const dotenv = require('dotenv')
updateEnv('./secrets/variables.env')
const app = require('./server/server')
const isProduction = process.env.NODE_ENV === 'production'
const port = (isProduction) ? 8080 : 5555
app.listen(port, '127.0.0.1', () => {
console.log('app listening on http://' + port)
})