node.js应用生成windows server的plugin——winser

针对项目中windows server machine 不断重启的问题,进行了许多方面修正的尝试:

第一是查系统日志,确定了重启的原因是系统自动更新而引起的,所以暂时把系统更新关闭了。然而考虑到未知的不确定因素导致server重启,考虑将node程序做成windows 的默认service。在系统重启的时候server会自动启动。 node.js有一个plugin提供了将node应用build为一个windows server 的功能,它就是winser。

我们简单使用如下:

1.安装winser $ npm install winser -g 我尝试不加-g,但是使用的时候报错,说找不到命令,所以最后还是安装成为全局的。

2.在node.js应用的package.json中指定应用的名字:

{ 
    "name":"JMarketPlace",
    "version":"0.0.1",
    "private":true,
    "scripts":{ "start":"node app" },
    "dependencies": { "express": "3.1.0", "jade":"*" }
}

3.在console下进入到app.js所在的目录:

$ winser –i 名字为JMarketPlace的服务就build成功了,如果想删除这个服务,用如下的命令:

$ winser –r 更详细的命令如下: -h, --help output usage information -V, --version output the version number -i, --install install the node application as a windows service -r, --remove remove the windows service for the node application -x, --stop stop the service before uninstalling -s, --silent supress any information in the console -c, --confirmation ask for confirmation before installing/uninstalling -p, --path [path] path to the node application you want to install as a service [current directory]

homepage for winser: https://github.com/jfromaniello/winser

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值