Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

node.js http server as a Windows service

I created a simple http server in Node.js.

I wanted to make it run permanently on my Windows 2008 machine, so that, if the computer reboots, it automatically restarts.

So I made it a service with this command:

C:\Users\Administrator>sc create translate binPath= "node D:\Apps\translate\machine-learning-server\servertranslate.js" DisplayName= "Translation Server"

Then started it with:

C:\Users\Administrator>sc start translate

and got the following error message:

[SC] StartService FAILED 1053:

The service did not respond to the start or control request in a timely fashion.

The program works OK when I start it from the command line (not as a service).

What is the easiest way to have a node.js web server that restarts automatically when the computer reboots?

like image 308
Erel Segal-Halevi Avatar asked Jul 14 '13 15:07

Erel Segal-Halevi


People also ask

Can you create an HTTP web server with node js?

The Node. js framework can be used to develop web servers using the 'http' module. The application can be made to listen on a particular port and send a response to the client whenever a request is made to the application.

Is node js a HTTP server?

Node. js has a built-in module called HTTP, which allows Node. js to transfer data over the Hyper Text Transfer Protocol (HTTP).


1 Answers

In the past, I've used NSSM for running Node.js applications as services on Windows. It works quite well, and can be configured to automatically restart your application in the event of a crash.

http://nssm.cc/usage

nssm install YourService "C:\Program Files\Node.js\node.exe" "C:\something\something.js"
like image 166
Brad Avatar answered Sep 22 '22 00:09

Brad