Search code examples
node.jswindowsforever

node.js forever arguments for background


I am trying to run my node.js app using forever on windows 64 bit. I have tried the followed, i installed foreman from npm . App is started with foreman start app.js. I observe that the node is running with my account. When logged out of the box the process stops. Is there away to start foreman and node to run with a system account so that its always running with out associating node to a specific user.

Any help would be greatly appreciated. TIA


Solution

  • You would need to run your app or forman either as a service or a scheduled task triggered to run at startup.

    I found this package that will replace forever and install pm2 as a service. https://www.npmjs.com/package/pm2-windows-service

    Using forever:

    There is at least this Stackoverflow question covering creating a service and probably others. Question about creating a service from an exe

    Creating a scheduled task tutorial

    Open Task scheduler:

    • Use windows search or control panel/administrative tools/Task Scheduler
    • You can also open a cmd console and copy %windir%\system32\taskschd.msc /s into it and hit enter.

    From there you can create a new task, set a schedule that triggers on startup, point it to forever and set it to run if your logged in or not. The link above, or other google results, will give you good tutorial info to work through it step by step.