Json-server: Can json-server running at background?

Created on 12 Jan 2016  路  9Comments  路  Source: typicode/json-server

I install json-server on Linux. And it works well when i type "json-server --watch db.json". But when I try to put json-server at background using commend "nohup json-server --watch db.json", error happened.
And here is the log file(nohup.out):
2016-01-12 5 05 20

help wanted

Most helpful comment

Hi,

In the next version of JSON Server (v0.9.2), the error will be caught:
https://github.com/typicode/json-server/commit/c527e1ef87ec79818c7c1376e8451676782e4f6e#diff-9676bb4e4701737e2a8e762cd177b0f6R165

It will be possible then to use nohup without workarounds :)

All 9 comments

Hmm can't seem to reproduce on OS X
I guess it's after you edit db.json that you have this error?

Reproducing on Linux...

yeah, I run this commend "nohup json-server --watch db.json" on Linux, not OS X. Have you found out the problem?

No sorry, didn't have the time to check that. So if anyone has an idea about it or want to help with this.

BTW I'm working on a tool for managing background servers, if you want to give a try https://github.com/typicode/hotel (it's not as simple as a nohup though).

I had experienced a similar problem, with a different version and hence line number:

events.js:72
throw er; // Unhandled 'error' event
^
Error: connect EACCES
at errnoException (net.js:901:11)
at Object.afterConnect as oncomplete

I am running:

Linux ip-172-30-2-68 3.13.0-83-generic #127-Ubuntu SMP Fri Mar 11 00:25:37 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

nodejs v0.10.25
json-server 0.8.10

Bad file descriptor feels like json-server isn't really pleased nohup leads to no stdin.

found workarround, give it something to read :
echo "\n" | nohup json-server db.json > logs.log &

I had same problem and seems i found workaround:
nohup json-server db.json </dev/null &

Also in my case json-server with nohup terminated after some time for an unknown reason, so if you'll have same issue you can try https://github.com/foreverjs/forever :

forever start /usr/local/bin/json-server /path/to/db.json

Hi,

In the next version of JSON Server (v0.9.2), the error will be caught:
https://github.com/typicode/json-server/commit/c527e1ef87ec79818c7c1376e8451676782e4f6e#diff-9676bb4e4701737e2a8e762cd177b0f6R165

It will be possible then to use nohup without workarounds :)

v0.9.2 with fix for nohup has just been published

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AdamCook44 picture AdamCook44  路  3Comments

pantchox picture pantchox  路  3Comments

0plus1 picture 0plus1  路  3Comments

dotmobo picture dotmobo  路  4Comments

goldmont picture goldmont  路  3Comments