I have developed push notification service using node js. For that I have to start the service manually each and every time.
How to start this service automatically? For example: If I logged-in, it should run automatically. thanks in advance
Nodemon is a package for handling this restart process automatically when changes occur in the project file. It will show the version of nodemon as shown in the below screenshot. Now, when we make changes to our nodejs application, the server automatically restarts by nodemon as shown in the below screenshot.
To restart the application automatically, use the nodemon module. This local installation of nodemon can be run by calling it from within npm script such as npm start or using npx nodemon.
Node.js files must be initiated in the "Command Line Interface" program of your computer. How to open the command line interface on your computer depends on the operating system. For Windows users, press the start button and look for "Command Prompt", or simply write "cmd" in the search field.
If you need a Windows service that starts when Windows start, you can use the sc create command to create the service.
e.g.
sc create MyServiceName binpath= "C:\Program Files\nodejs\node.exe C:\somefolder\service.js" start= auto depend= "Tcpip/Afd" DisplayName= "A friendly name for my service"
Mind the spaces after the = signs.
You can find more information here: https://technet.microsoft.com/en-us/library/cc990289.aspx
If you need the application to start when you log-in instead, you can use regedit.exe to create a REG_SZ entry containing your command in the following registry path:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With