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

后端 未结 6 717
南方客
南方客 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:05

    Here's an adjusted version of Pendlepants solution. Foreman looks for an .env file to read environment variables. Rather than adding a wrapper, you can just have Foreman switch what command it uses to start things up:

    In .env:

    WEB=node app.js
    

    In dev.env:

    WEB=supervisor app.js
    

    In your Procfile:

    web: $WEB
    

    By default, Foreman will read from .env (in Production), but in DEV just run this:

    foreman start -e dev.env
    

提交回复
热议问题