Fix nohup issue

This commit is contained in:
typicode
2016-11-28 13:30:43 +01:00
parent 2ce7cd37b2
commit c527e1ef87
2 changed files with 10 additions and 1 deletions

View File

@ -160,7 +160,11 @@ module.exports = function (argv) {
chalk.gray(' Type s + enter at any time to create a snapshot of the database')
)
process.stdin.resume()
// Support nohup
// https://github.com/typicode/json-server/issues/221
process.stdin.on('error', (err) => {
console.log(' Error, can\'t read from stdin')
})
process.stdin.setEncoding('utf8')
process.stdin.on('data', (chunk) => {
if (chunk.trim().toLowerCase() === 's') {