When I run nodejs http server program, it will be timed out if starting it at "service mynodehttp start" at linux shell . Why it will be timed out after 1-2 minutes if no any client request ? If I check with "systemctl status mynodehttp.service", it showed as follows mynodehtttp.service operation timed out. Terminating
But it won't time out if I run it at linux shell directly . why ? How to set the longer timeout in the following program by service or systemctl command on linux
var http = require('http'),
fs = require('fs');
fs.readFile('/home/user/public_html/data/nodejs/junk.txt', function (err, html) {
if (err) { throw err; }
http.createServer(function(request, response) {
//response.writeHeader(200, {"Content-Type": "text/html"});
response.setHeader('Content-Type', 'text/html; charset=UTF-8');
response.writeHead(200);
// response.connection.setTimeout(3000000);
response.write(html);
response.end();
}).listen(8000);
});
Please advise