Search code examples
loopbackjsstronglooploopbackforever

How to run Node.JS Loopback + Forever?


How do I run StrongLoop's Loopback with Forever so that the app is automatically restarted after ever change?

So far just running forever server/server.js doesn't seem to work...


Solution

  • Thanks. I have found that the best script is this:

    "scripts": {
        "start": "forever --verbose --uid \"myapp\" --watch --watchDirectory ./server server/server.js"
      },
    

    Each part means:

    --verbose: Log all details (useful when developing new routes)

    --uid \"myapp\": So that "myapp" will appear when you do a forever list

    --watch: Watch for file changes

    --watchDirectory ./server: The folder to watch for changes

    server/server.js: The app entry point

    Additionally I open it with like nohup npm start & so that the process will keep running in the background and the output will be appended to a nohup.out file.