简体   繁体   中英

NodeJS, how can I use 'forever start' from a batch file?

Edit: I got it to work, but I forgot to mention that I'd like the console to remain open so I can see what's going on in real time. Is there a way to keep the console open somehow? thx!

so my nodejs app crashes sometimes, and in order to reset it I use 'forever start index.js'

Problem is, I'm currently starting it from a .bat file and Idk how to start my app forever with the batch file

My .bat file looks like this:

"forever start index.js"

Thx for the help

"forever start index.js"

expecting my app to reset whenever it crashed

To answer your edit:

Edit: I got it to work, but I forgot to mention that I'd like the console to remain open so I can see what's going on in real time. Is there a way to keep the console open somehow? thx!

Run the bat file from the command line, not by double-clicking on it.

You can do this by:

  1. Ctrl+R -> "CMD"
  2. Navigate to the folder your bat file is in with cd C:/myDir/etc/
  3. Double check your bat file is present in the directory you have your command prompt looking at by entering dir and reading the output
  4. Once you've found it, enter start ./myfile.bat and the CMD window will stay open.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM