Can I tell foreman to reload the web app every time a request is made so I can develop decently?

后端 未结 6 711
南方客
南方客 2020-12-24 13:18

A web app I am writing in JavaScript using node.js. I use Foreman, but I don\'t want to manually restart the server every time I change my code. Can I tell Foreman to reload

6条回答
  •  遥遥无期
    2020-12-24 14:12

    You don't even need to install anything new if you use node-dev.

    Your .env file loaded from Procfile:

    NODECMD=node-dev
    

    Your Procfile:

    web: $NODECMD app/server.js
    

    Your foreman command

    foreman start -e dev.env -p 9786
    

    And in your production env (heroku) set an environment variable:

    NODECMD=node
    

提交回复
热议问题