nodemon cannot run in background with nohup?

Created on 14 Feb 2014  ·  34Comments  ·  Source: remy/nodemon

I use nohup nodemon server.js &. It seems nodemon is killed soon.

help wanted

Most helpful comment

this may be help: nohup nodemon app.js </dev/null &

details: https://github.com/remy/nodemon/issues/98

All 34 comments

Is killed, as in, dies? Or does it linger, then restart? I could do with a bit more information. Perhaps some help debugging?

I run nodemon, everything is fine as below.

    [root@vm dms]# nodemon server/server.js
    19 Feb 02:53:23 - [nodemon] v1.0.14
    19 Feb 02:53:23 - [nodemon] to restart at any time, enter `rs`
    19 Feb 02:53:23 - [nodemon] watching: *.*
    19 Feb 02:53:23 - [nodemon] starting `node server/server.js`

But nohup not work.

    [root@vm dms]#
    [root@vm dms]# nohup nodemon server/server.js &
    [1] 19973
    [root@vm dms]# nohup: ignoring input and appending output to `nohup.out'
    [1]+  Exit 1                  nohup nodemon server/server.js

Here is the log of nohup.out

    [root@vm dms]# cat nohup.out
    -----------------------------------------
    Update available: 1.0.15 (current: 1.0.14)
    Run npm update -g nodemon to update
    -----------------------------------------
    19 Feb 02:53:53 - [nodemon] v1.0.14
    19 Feb 02:53:53 - [nodemon] to restart at any time, enter `rs`
    19 Feb 02:53:53 - [nodemon] watching: *.*
    19 Feb 02:53:53 - [nodemon] starting `node server/server.js`
    exception in nodemon killing node
    Error: EBADF, read

    If appropriate, please file an error:
    http://github.com/remy/nodemon/issues/new

On Wed, Feb 19, 2014 at 4:48 AM, Remy Sharp [email protected]:

Is killed, as in, dies? Or does it linger, then restart? I could do with a
bit more information. Perhaps some help debugging?


Reply to this email directly or view it on GitHubhttps://github.com/remy/nodemon/issues/296#issuecomment-35431654
.

I'm also facing the same issue. I tried to run nodemon in verbose mode but it didn't help much. Here's what happens when I try to run nodemon with nohup :

work:~/workspace/discovery-logging > nohup nodemon --verbose serve.js &
[1] 22313
work:~/workspace/discovery-logging > nohup: ignoring input and appending output to `nohup.out'

[1] + exit 1 nohup nodemon --verbose serve.js

work:~/workspace/discovery-logging >
work:~/workspace/discovery-logging > cat nohup.out
5 Mar 04:27:30 - [nodemon] v1.0.15
5 Mar 04:27:30 - [nodemon] to restart at any time, enter rs
5 Mar 04:27:30 - [nodemon] ignoring: /home/user/workspace/discovery-logging/.git//* node_modules//node_modules
5 Mar 04:27:30 - [nodemon] watching: _._
5 Mar 04:27:30 - [nodemon] watching extensions: js
5 Mar 04:27:30 - [nodemon] starting node serve.js
5 Mar 04:27:30 - [nodemon] child pid: 22319
exception in nodemon killing node
Error: EBADF, read

If appropriate, please file an error: http://github.com/remy/nodemon/issues/new

5 Mar 04:27:30 - [nodemon] exiting

Can someone run the exact same command, but add --dump and then post the output here?

-----------------------------------------
Update available: 1.0.17 (current: 1.0.15)
Run npm update -g nodemon to update
-----------------------------------------
25 Apr 13:41:14 - [nodemon] v1.0.15
25 Apr 13:41:14 - [nodemon] to restart at any time, enter `rs`
25 Apr 13:41:14 - [nodemon] ignoring: /home/aamir/workspace/saiku-ui/.git/**/* node_modules/**/node_modules
25 Apr 13:41:14 - [nodemon] watching: *.*
25 Apr 13:41:14 - [nodemon] watching extensions: js
--------------

{ run: false,
  system: 
   { cwd: '/home/aamir/workspace/saiku-ui',
     useFind: false,
     useWatch: true,
     useWatchFile: false },
  required: false,
  dirs: [ '/home/aamir/workspace/saiku-ui' ],
  timeout: 1000,
  options: 
   { scriptPosition: 1,
     dump: true,
     verbose: true,
     script: 'serve.js',
     args: [],
     ignore: 
      [ '.git',
        'node_modules/**/node_modules',
        re: /\.git|node_modules/.*.*/node_modules/ ],
     watch: [ '*.*', re: /.*\..*/ ],
     restartable: 'rs',
     execMap: { py: 'python', rb: 'ruby' },
     stdin: true,
     stdout: true,
     execOptions: 
      { script: 'serve.js',
        exec: 'node',
        nodeArgs: undefined,
        ext: 'js',
        env: {},
        execArgs: [] },
     ext: 'js',
     monitor: 
      [ '*.*',
        '!/home/aamir/workspace/saiku-ui/.git/**/*',
        '!node_modules/**/node_modules' ] },
  load: [Function],
  reset: [Function: reset],
  lastStarted: 0,
  loaded: [],
  command: 
   { raw: { executable: 'node', args: [ 'serve.js' ] },
     string: 'node serve.js' } }

--------------
OS: linux ia32
node: v0.10.26
nodemon: v1.0.15
cwd: /home/aamir/workspace/saiku-ui
command: node /usr/bin/nodemon --dump --verbose serve.js
--------------
25 Apr 13:41:14 - [nodemon] exiting
-bash-4.1# nohup nodemon --dump server/server.js &
[1] 30753
-bash-4.1# nohup: ignoring input and appending output to `nohup.out'

[1]+  Done                    nohup nodemon --dump server/server.js

-bash-4.1# cat nohup.out

-----------------------------------------
Update available: 1.0.17 (current: 1.0.14)
Run npm update -g nodemon to update
-----------------------------------------
25 Apr 18:47:03 - [nodemon] v1.0.14
25 Apr 18:47:03 - [nodemon] to restart at any time, enter `rs`
25 Apr 18:47:03 - [nodemon] watching: *.*
--------------
{ run: false,
  system: 
   { cwd: '/www/app/dms',
     useFind: false,
     useWatch: true,
     useWatchFile: false },
  required: false,
  dirs: [ '/www/app/dms' ],
  timeout: 1000,
  options: 
   { scriptPosition: 1,
     dump: true,
     script: 'server/server.js',
     args: [ 'server/server.js' ],
     ignore: 
      [ '.git',
        'node_modules/**/node_modules',
        re: /\.git|node_modules/.*.*/node_modules/ ],
     watch: [ '*.*', re: /.*\..*/ ],
     restartable: 'rs',
     execMap: { py: 'python', rb: 'ruby' },
     stdin: true,
     verbose: false,
     stdout: true,
     execOptions: 
      { script: 'server/server.js',
        exec: 'node',
        nodeArgs: undefined,
        ext: 'js',
        env: {},
        execArgs: [] },
     ext: 'js',
     monitor: [ '*.*', '!.git', '!node_modules/**/node_modules' ] },
  load: [Function],
  reset: [Function: reset],
  lastStarted: 0,
  loaded: [],
  command: 
   { raw: 
      { executable: 'node',
        args: [ 'server/server.js', 'server/server.js' ] },
     string: 'node server/server.js server/server.js' } }
--------------
OS: linux ia32
node: v0.10.25
nodemon: v1.0.14
cwd: /www/app/dms
command: node /usr/local/bin/nodemon --dump server/server.js
--------------

I had same issue. Here is my work around
Created a shell script exec.sh

cd source
nodemon app.js

Then execute the script with nohup

nohup exec.sh

Cheers for the tip. I've not had a chance to play with this yet (am on
paternity leave), but I'll take a look too. I suspect there's some kind of
signalling going weird here.

On Tuesday, May 6, 2014, Sriraman [email protected] wrote:

I had same issue. Here is my work around
Created a shell script exec.sh

cd source
nodemon app.js

Then execute the script with nohup

nohup exec.sh


Reply to this email directly or view it on GitHubhttps://github.com/remy/nodemon/issues/296#issuecomment-42283303
.

— Remy

@sparkit noop, the ways produce the same error...

this may be help: nohup nodemon app.js </dev/null &

details: https://github.com/remy/nodemon/issues/98

I have same problem, how can make it work, please help

@nvcken
Did you tried the solution I posted ?

I has try nohup nodemon But not work, I got log

8 Jul 15:00:57 - [nodemon] v1.2.0
8 Jul 15:00:57 - [nodemon] to restart at any time, enter rs
8 Jul 15:00:57 - [nodemon] watching: _._
8 Jul 15:00:57 - [nodemon] starting node ./bin/www
events.js:85
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE
at exports._errnoException (util.js:742:11)
at Server._listen2 (net.js:1126:14)
at listen (net.js:1148:10)
at Server.listen (net.js:1223:5)
at Server.listen (/var/www/appota_inside/node_modules/livereload/lib/livereload.js:69:28)
at Object.exports.createServer (/var/www/appota_inside/node_modules/livereload/lib/livereload.js:201:12)
at Object. (/var/www/appota_inside/app.js:28:21)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:349:32)
8 Jul 15:00:58 - [nodemon] app crashed - waiting for file changes before starting...

@sparkit
I has try as your guide. But not work
I got this log

8 Jul 15:06:49 - [nodemon] v1.2.0
8 Jul 15:06:49 - [nodemon] to restart at any time, enter rs
8 Jul 15:06:49 - [nodemon] watching: _._
8 Jul 15:06:49 - [nodemon] starting node ./bin/www
exception in nodemon killing node
Error: EBADF, read
at Error (native)


If appropriate, please file an error with the output from:
$ node /usr/local/bin/nodemon --dump

At http://github.com/remy/nodemon/issues/new

@sparkit
I use nohup ./exec.sh, because nohup exec.sh not work, because it show "nohup: cannot run command `exec.sh': No such file or directory"

Have added permission +x for exec.sh ?
try giving full path nohup

I has added +x permission for exec.sh.
Could you please explain how give full path nohup, thanks

Will look something like
nohup /home/nvcken/myapp/exec.sh

On Tue, Jul 8, 2014 at 1:48 PM, nvcken [email protected] wrote:

I has added +x permission for exec.sh.
Could you explain how give full path nohup, thanks


Reply to this email directly or view it on GitHub
https://github.com/remy/nodemon/issues/296#issuecomment-48284117.

I get nohup nodemon work, now.
But It seem occur error when file js change, nodemon auto restart but

8 Jul 15:39:02 - [nodemon] restarting due to changes...
8 Jul 15:39:03 - [nodemon] starting node ./bin/www
8 Jul 15:39:03 - [nodemon] starting node ./bin/www
events.js:85
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE

I lookup grep node, has a node process with listening port 35729 running.
If I kill it, nodemon start ok.
What happen ?

Could you please paste here

a) nohup command you are running
b) Your exec.sh

Thanks

On Tue, Jul 8, 2014 at 2:15 PM, nvcken [email protected] wrote:

I got nohup nodemon work, now.
But It seem occur error when file js change, nodemon auto restart but

8 Jul 15:39:02 - [32m[nodemon] restarting due to changes...[39m
8 Jul 15:39:03 - [32m[nodemon] starting node ./bin/www[39m
8 Jul 15:39:03 - [32m[nodemon] starting node ./bin/www[39m

events.js:85
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE

I lookup grep node, has a node process with listen port 35729 running.
If I kill it, nodemon start ok.
What happen ?


Reply to this email directly or view it on GitHub
https://github.com/remy/nodemon/issues/296#issuecomment-48286361.

I use only command below
nohup nodemon

Thanks

I added an issue to nodejs, because I was having the same issue when binding to stdin. It might be related this issue, too.

https://github.com/joyent/node/issues/8410

@remy I bet if you remove these lines, it will work without issues using nohup :)

https://github.com/remy/nodemon/blob/master/lib/nodemon.js#L106

nohup nodemon app.js works for me!
thanks!

nohup nodemon app.js works for me too!
Thank you very much ;-)

i can put it to background, but after close ssh connection, nodemon stopped, because after connecet to ssh again i dont have any package on background

Last login: Mon Jul 25 10:01:35 2016 from 46.224.238.119 hello@ubuntu:~$ fg -bash: fg: current: no such job

Another possible solution:

nohup nodemon -I app.js

The -I switch prevents nodemon from attempting to use STDIN, which isn't allowed under nohup as there's no input stream.

~@Fistynuts interesting -- but I don't see the -I option when I run nodemon --help. Doc issue?~
Never mind, my eyes deceived me.

@barraponto please use tmux terminal emulator and run nodejs application inside that

This issue has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and @remy will (try!) to follow up.
Thank you for contributing <3

@leoliaolei you can use nodemon with tmux

@remy Feel free to close this issue, the -I switch fixes it.

I've got an faq item to merge, so I'll add this to the FAQ too.

👍

For those trying to use it (I don't have the -I switch yet on the version I installed), you can also try with the command "screen" if your distribution has it (AWS has it), it opens a deattached shell which wont die even if your ssh dies (plus you can recover it later)

nohup nodemon app.js works for me!
thanks!

thanks this is work for me

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jonerer picture jonerer  ·  4Comments

piton13 picture piton13  ·  3Comments

Makoehle picture Makoehle  ·  3Comments

Mohammad-Quanit picture Mohammad-Quanit  ·  5Comments

dimsmol picture dimsmol  ·  4Comments