Created
December 18, 2017 02:08
-
-
Save hoangsetup/3b2101ec0befef0f5b38b25c4b69b1d6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var fs = require('fs'); | |
fs.writeFile('env.temp', `DATA_DIR=${process.env.DATA_DIR}`, function (err) { | |
if (err) { | |
return console.log(err); | |
} | |
console.log('The file was saved!'); | |
}); |
This file contains hidden or 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
var pm2 = require('pm2'); | |
process.env.DATA_DIR = '/var/lib/data'; | |
pm2.connect(function (err) { | |
if (err) { | |
console.error(err); | |
process.exit(2); | |
} | |
pm2.start({ | |
name: 'app', | |
script: 'app.js', // Script to be run | |
exec_mode: 'fork', // Allows your app to be clustered | |
instances: 1, // Optional: Scales your app by 4 | |
max_memory_restart: '100M' // Optional: Restarts your app if it reaches 100Mo | |
}, function (err, apps) { | |
pm2.disconnect(); // Disconnects from PM2 | |
if (err) throw err | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment