我在Node.js中创build了一个简单的http服务器。
我想让它在Windows 2008计算机上永久运行,这样,如果计算机重新启动,它会自动重新启动。
所以我用这个命令做了一个服务:
C:UsersAdministrator>sc create translate binPath= "node D:Appstranslatemachine-learning-serverservertranslate.js" displayName= "Translation Server"
然后开始:
Socket.io无法在Nginx + node.js + PHP应用程序中连接
在启动Windows上运行nodejs应用程序
如何在同一台服务器上使用Nginx将PHP和nodejs应用程序一起configuration
基本Node.js的例子不适用于Windows 7
C:UsersAdministrator>sc start translate
并得到以下错误信息:
[SC] StartService Failed 1053: The service did not respond to the start or control request in a timely fashion.
程序工作正常,当我从命令行(而不是服务)启动它。
让计算机重新启动时自动重新启动node.js Web服务器的最简单方法是什么?
在Jenkins中使用maven exec插件运行nodejs
从子文件夹服务Express.JS应用程序
带有模拟的Child_process?
Socket.IO无法调用“打开”
在过去,我使用NSSM在Windows上运行Node.js应用程序作为服务。 它工作得很好,可以配置为在发生崩溃时自动重启应用程序。
http://nssm.cc/usage
nssm install YourService "C:Program FilesNode.jsnode.exe" "C:somethingsomething.js"
我记得,Service运行时环境与在命令行下运行的东西不一样。 特别是,需要服务来响应来自系统的消息以指示其运行状态,如您所见:-)
果然: https : //npmjs.org/package/windows-service
窗口服务
像本机Windows服务一样运行Node.JS程序。
npm安装windows-service
正如其他人在其他问题中提到的,我想在这里分享一个名为WinSer的node.js模块,它包装了NSSM,它的用法非常简单,也许它有一天会帮助别人。
:)
使用这个,真的很简单https://github.com/coreybutler/node-windows
在您的项目上创建两个js文件。 并运行这些
节点your_service.js节点your_service_remove.js
安装:
/** * Created by sabbir on 08/18/2015. */ //ref: https://github.com/coreybutler/node-windows var Service = require('node-windows').Service; // Create a new service object var svc = new Service({ name:'nodeDemoApp',description: 'The nodejs.org example web server.',script: 'D:\NodeJS\demoWeb\bin\www' }); // listn for the "install" event,which indicates the // process is available as a service. svc.on('install',function(){ svc.start(); }); svc.install();
对于卸载:
var Service = require('node-windows').Service; // Create a new service object var svc = new Service({ name:'nodeDemoApp',script: require('path').join(__dirname,'bin\www') }); // listn for the "uninstall" event so we kNow when it's done. svc.on('uninstall',function(){ console.log('Uninstall complete.'); console.log('The service exists: ',svc.exists); }); // Uninstall the service. svc.uninstall();
在猜测,我会说,该服务不知道在哪里可以找到节点的二进制文件。 你可能已经更新了你的配置文件的PATH变量。 我的建议是总是硬编码服务脚本的完整路径。
你可以试试这个包qckwinsvc 。 首先在全球安装:
npm install -g qckwinsvc
然后从cmd:
qckwinsvc prompt: Service name: [...] prompt: Service description: [...] prompt: Node script path: [/path/to/.js file]
要卸载:
qckwinsvc --uninstall
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。