nodemon cannot run in background with nohup? #296

Open
leoliaolei opened this Issue Feb 14, 2014 · 25 comments

Projects

None yet

10 participants

@leoliaolei

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

@remy
Owner

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

@leoliaolei
@syst3mw0rm

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

@remy
Owner

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

@syst3mw0rm
-----------------------------------------
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
@leoliaolei
-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
--------------
@sparkit

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
@remy
Owner
@remy remy added help wanted and removed needs more info labels May 10, 2014
@beetaa

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

@beetaa

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

details: #98

@nvcken

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

@sparkit

@nvcken
Did you tried the solution I posted ?

@nvcken

I has try nohup nodemon </dev/null &
But not work, I got log

8 Jul 15:00:57 - �[33m[nodemon] v1.2.0�[39m
8 Jul 15:00:57 - �[33m[nodemon] to restart at any time, enter rs�[39m
8 Jul 15:00:57 - �[33m[nodemon] watching: .�[39m
8 Jul 15:00:57 - �[32m[nodemon] starting node ./bin/www�[39m
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 - �[31m[nodemon] app crashed - waiting for file changes before starting...�[39m

@nvcken

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

8 Jul 15:06:49 - �[33m[nodemon] v1.2.0�[39m
8 Jul 15:06:49 - �[33m[nodemon] to restart at any time, enter rs�[39m
8 Jul 15:06:49 - �[33m[nodemon] watching: .�[39m
8 Jul 15:06:49 - �[32m[nodemon] starting node ./bin/www�[39m
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

@nvcken

@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"

@sparkit

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

@nvcken

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

@sparkit
@nvcken

I get 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 listening port 35729 running.
If I kill it, nodemon start ok.
What happen ?

@sparkit
@nvcken

I use only command below
nohup nodemon </dev/null &

Thanks

@cookiengineer

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

nodejs/node-v0.x-archive#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

@nswish

nohup nodemon app.js </dev/null &
works for me!
thanks!

@rodrigogds

nohup nodemon app.js </dev/null &
works for me too!
Thank you very much ;-)

@tux-world
tux-world commented Jul 25, 2016 edited

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment