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

from:http://xiaomijsj.blog.163.com/blog/static/89685520135854036206/

 

针对项目中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   

posted @   94cool  阅读(1524)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示