nodejs forever : How to run my npm application

前端 未结 3 537
天涯浪人
天涯浪人 2021-02-07 11:34

Right now i am runnign my nodejs application as npm start. i want to run it in background. I found forever package for this but dont know how can i run

3条回答
  •  甜味超标
    2021-02-07 11:56

    You are doing it right.

    The warnings are just reminding you that some essential information is missing, so it assigns the defaults. To be exact, if your script crashes/exits sooner than a second after start, forever will exit as well.


    If you would like to get rid of those warnings:

    forever start --minUptime 1000 --spinSleepTime 1000 app.js 
    

    Furthermore, you can open the package.json file, find the:

      "scripts": {
        "start": "node app.js"
      },
    

    and change it to:

      "scripts": {
        "start": "forever start --minUptime 1000 --spinSleepTime 1000 app.js",
        "stop":  "forever stop app.js"
      },
    

    Now you can use npm start and it will invoke forever automatically.

提交回复
热议问题