如何将node.js安装为Windows服务? [英] How to install node.js as windows service?
本文介绍了如何将node.js安装为Windows服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经下载了 node.js 可执行文件.如何将可执行文件作为Windows服务运行? 我无法使用标准的node.js安装程序,因为我需要同时运行多个版本的node.js.
I have downloaded node.js executable. How can I run that executable as windows service? I cannot use standard node.js installer, since I need to run multiple version of node.js concurrently.
推荐答案
晚了聚会,但 node- Windows 也可以解决问题.
Late to the party, but node-windows will do the trick too.
它还内置了系统日志记录.
It also has system logging built in.
有一个API可通过代码创建脚本,即
There is an API to create scripts from code, i.e.
var Service = require('node-windows').Service;
// Create a new service object
var svc = new Service({
name:'Hello World',
description: 'The nodejs.org example web server.',
script: 'C:\\path\\to\\helloworld.js'
});
// Listen for the "install" event, which indicates the
// process is available as a service.
svc.on('install',function(){
svc.start();
});
svc.install();
FD:我是这个模块的作者.
FD: I'm the author of this module.
这篇关于如何将node.js安装为Windows服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文