-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
. . Hi there. Currently I have a very specific setup in the machine running the app I'm working on. Sadly I don't have direct access to the server and I need the app to run as smoothly as possible, but I also need a way to update the code. Since I can't access the server to restart the process, I used forever (in Node.JS) to keep it running.
. . As I needed to update the server frequently, I wrapped the "forever.js" script (that runs my "server.js"--that runs a HTTP and Socket servers) in a nodemon process.
. . The thing is: as I change a file, the nodemon process restart the forever.js, but then the forever.js runs an infinite loop of error/respawn with the following error message:
{ stack: [Getter/Setter],
arguments: undefined,
type: undefined,
message: 'EADDRINUSE, Address already in use',
errno: 98,
code: 'EADDRINUSE',
syscall: 'bind' }
. . If I manually do a Ctrl+C and restart the nodemon command ("nodemon -d 6 forever.js") it start ok again (even when it's in the forever error loop), but as soon as I change a file, my script goes into the "address in use" error loop again. I don't know if nodemon is not actually closing the process and the port bind hangs or something... If you have any tips I would greatly appreciate it.
. . I though about not using the forever.js (running "nodemon -d 6 server.js" rather then "forever.js") because when starting this way the server restarts ok if I save a file, but I really need the forever.js to restart my server automatically if an error occurs because I can't afford the downtime until I manually upload a file again (so that nodemon restart my server).
. . PS: it is worth mentioning that my server restarts ok when an error occurs if I run "node forever.js" directly, without "nodemon", so the problem seems to be using both of them together.
. . Do you have any tips?