Kiran
Kiran

Reputation: 1197

What are the different ways to run a node.js file indefinitely in windows server?

I know we can run a node.js file in windows via the command prompt like below

cd c:\wamp\www\myfolder
c:\wamp\www\myfolder>node testing.js

My question is, How can I automate this file to run indefinitely for every 10 second or 1 minute in windows?

As of now I have created a scheduler in windows system which is running every 1 minute to execute my js file. I have created a .bat file with required commands and put it in the scheduler. So it is running perfectly. I want to know, are there any other best solutions available?

One more question I have is, every time I run "node testing.js" command, does node js will create a new server instance or will it use the same / old instance which is created earlier. What is the mechanism behind that.

Upvotes: 0

Views: 1817

Answers (2)

solick
solick

Reputation: 2345

Please have a look at foreverjs

https://github.com/foreverjs/forever

I found it very flexible and reliable.

Upvotes: 0

T.J. Crowder
T.J. Crowder

Reputation: 1074276

How can I automate this file to run indefinitely for every 10 second or 1 minute in windows?

You can use Windows' task scheduler to do that. It has both a UI and an API.

Alternately, rather than running every 10 seconds, you might run it as a service.

Upvotes: 3

Related Questions