2

I'm trying to use nodemon with forever.

I have no problems with nodemon alone:

nodemon --exitcrash node/index.js -- "user/verbs/config"

However, in following the instructions in the nodemon FAQ, and putting quotes around "nodemon --exitcrash" as per the comment at https://stackoverflow.com/a/20306929/271577 (to avoid forever thinking the argument "user/verbs/config" is the file) to produce:

forever start --minUptime 1000 --spinSleepTime 1000 --killSignal=SIGTERM -c "nodemon --exitcrash" node/index.js -- "user/verbs/config"

...I get the message

info: Forever processing file: node/index.js

and no continuation of the script. Running forever list shows "No forever processes running".

(Note: I eventually want this working with forever-monitor, but I figure the above will need to work first.)

Is there something I'm missing?

Community
  • 1
  • 1
Brett Zamir
  • 14,034
  • 6
  • 54
  • 77
  • 1
    I don't know the specific tools involved, but you should note that in your second command it is `forever` that receives `-- "user/verbs/config"` as arguments, not `nodemon`, as in your first command. – mklement0 Jul 19 '16 at 04:46
  • Hmm..Since nodemon is supposed to pass on whatever is after the ` -- ` onto the script (i.e., "node/index.js" in this case), any idea how I'd do that? – Brett Zamir Jul 19 '16 at 04:58
  • 1
    I see, so I may have been wrong in that it sounds like `forever` passes whatever follows the `SCRIPT` argument through to the latter. One thing that's not obvious from `forever`'s help: does `-c` really accept a command _line_ (executable + options) rather than a mere command _name_ (name/path of an executable)? If it's only the latter, you may have to write an executable wrapper shell script that wraps the `nodemon --exitcrash` call. – mklement0 Jul 19 '16 at 05:11
  • The notes about ` -- ` were only for nodemon by itself, not necessarily with `forever`. In any case, I added a script to add the `"user/verbs/config"` argument so it was not necessary to pass it in the command line to `forever` and tried a node script to wrap `nodemon --exitcrash`, but it still did not work (at least where I'm trying it, on Windows). – Brett Zamir Jul 20 '16 at 00:33
  • 1
    That you're trying this on Windows is definitely worth mentioning; the wrapper script passed to `-c` should be a `.cmd` (`.bat`) file that has `--exitrcrash` and `"user/verbs/config"` hard-coded into it, with the `.js` file passed as a parameter, though you'll have to test if `forever` is capable of invoking a batch file directly. – mklement0 Jul 20 '16 at 02:06
  • Having some computer and health problems, atm, but thank you, I will check that out as I can. – Brett Zamir Jul 22 '16 at 04:57
  • 1
    Sorry to hear it - best of luck. – mklement0 Jul 22 '16 at 04:58

1 Answers1

0
forever -c "nodemon --exitcrash" app.js

this makes sure nodemon actually exits (rather than giving you the "app crashed" message) and then forever picks it up again.

In forever --help this -c specifies a command to run otherwise it defaults node. Without -c results in the error that is mention in the comments to this answer.

Source

Permanently
  • 344
  • 2
  • 3
  • 13