Wednesday, December 7, 2016

Easy Step: Auto Start NodeJs Server on Startup Windows

Overview: Generally, when we start server nodejs we use command node server.js or node bin/www for express framework. Restarting or start computer you need to run that command line again. In the article I will show you some tips to solve to issue.

Objective: When computer startup service node js is automatically started.
  • Forever: make process run continuously and automatically restart when it exits unexpectedly.
Implementation
  • Install forever in globally 
    npm install -g forever
  • Create VbScript for executing project: I put it in root of project directory   
    Set WshShell = WScript.CreateObject("WScript.Shell")
    Return = WshShell.Run("cmd.exe /C forever start bin/www", 1, true)
  • Startup folder
    You can link VBscript file(shortcut) to startup folder

  • Restart computer 

No comments:

Post a Comment