TN.*_*TN. 120 windows-services node.js
我已经下载了node.js可执行文件.如何将该可执行文件作为Windows服务运行?我不能使用标准的node.js安装程序,因为我需要同时运行多个版本的node.js.
Cor*_*rey 172
晚到派对,但节点窗口也会起作用.
它还内置了系统日志记录.
有一个API可以从代码创建脚本,即
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();
Run Code Online (Sandbox Code Playgroud)
FD:我是这个模块的作者.
Har*_*pal 32
我发现这个东西非常有用,我在它周围构建了一个更容易使用的包装器(npm,github).
安装它:
npm install -g qckwinsvc
Run Code Online (Sandbox Code Playgroud)
安装您的服务:
qckwinsvc
prompt: Service name: [name for your service]
prompt: Service description: [description for it]
prompt: Node script path: [path of your node script]
Service installed
Run Code Online (Sandbox Code Playgroud)
卸载您的服务:
qckwinsvc --uninstall
prompt: Service name: [name of your service]
prompt: Node script path: [path of your node script]
Service stopped
Service uninstalled
Run Code Online (Sandbox Code Playgroud)
Pre*_*vić 27
WinSer是一个node.js友好包装流行的NSSM(非吸吮服务管理器)
Mic*_*ski 15
接下来,我想将节点作为服务托管,就像IIS一样.这样它就可以启动我的机器,在后台运行,如果它崩溃则自动重启等等.
这就是非吸烟服务经理nssm进入图片的地方.此工具允许您将普通.exe作为Windows服务托管.
以下是我用于将节点应用程序实例设置为服务的命令,像管理员一样打开cmd并键入以下命令:
Run Code Online (Sandbox Code Playgroud)nssm.exe install service_name c:\your_nodejs_directory\node.exe c:\your_application_directory\server.js net start service_name