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

node.js应用生成windows service的plugin——winser的更多相关文章

  1. Windows使用Node.js自动生成Vue.js模版环境部署步骤-----记录

    node.js官网下载并安装node 进入node文档目录下,运行cmd 输入 node -v 查看node版本 出现表示安装完成 输入 npm -v 显示npm版本信息 安装cnpm 输入 npm ...

  2. node.js压缩版 Windows安装

    1.下载 下载地址:https://nodejs.org/zh-cn/download/ 选择相应的版本下载 2.解压缩 将文件解压到要安装的位置,并新建两个目录 node-global :npm全局 ...

  3. Node.js快速生成26个字母

    const buf1 = Buffer.allocUnsafe(26); for (let i = 0; i < 26; i++) { // 97 是 'a' 的十进制 ASCII 值. buf ...

  4. windows中安装node.js和测试

    首先下载node.js安装包:下载页面:http://down.keleyi.com/goto/node.js.htm 选择windows msi安装包,根据自己操作系统选择32位或者64位安装包.然 ...

  5. 用Node.js开发Windows 10物联网应用

    (此文章同时发表在本人微信公众号"dotNET每日精华文章",欢迎右边二维码来关注.) 未来10年内,物联网将会如移动互联网这样深入到我们生活的各方各面.所以微软现在对物联网进行了 ...

  6. PostMan生成的测试报告 工具node.js、步骤、结果

    Postman生成测试报告的工具node.js 1.下载并安装: win系统(下载后一直下一步就好了) mac系统  2.配置环境 (1).在命令提示符里面输入npm 检验安装是否成功可以输入命令:n ...

  7. A chatroom for all! Part 1 - Introduction to Node.js(转发)

    项目组用到了 Node.js,发现下面这篇文章不错.转发一下.原文地址:<原文>. ------------------------------------------- A chatro ...

  8. Node.js入门(含NVM、NPM、NVM的安装)

    本文最初发表于博客园,并在GitHub上持续更新前端的系列文章.欢迎在GitHub上关注我,一起入门和进阶前端. 以下是正文. Node.js的介绍 引擎 引擎的特性: JS的内核即引擎.因为引擎有以 ...

  9. Node.js 介绍

    章节 Node.js 介绍 Node.js 入门 Node.js 模块 Node.js HTTP模块 Node.js 文件系统模块 Node.js URL模块 Node.js NPM Node.js ...

随机推荐

  1. 28. Implement strStr()【easy】

    28. Implement strStr()[easy] Implement strStr(). Returns the index of the first occurrence of needle ...

  2. string 的函数

    string 有一个很好用到函数:substr(index). 去掉前index个字符.

  3. java & c sharp 的关联

    第一.java是真正的与平台无关,c sharp不是,他只是口头上的与平台无关,最后,却要靠别人来实现非微软平台的类库. 第二.java中的类名.class 和c#的 typeof(类名)或者getT ...

  4. springboot解决第三方依赖jar包的问题

    公司现在用的是springboot+maven,想要把一些老的项目都改成这种框架.但是一些老的项目中有好多第三方的jar包或者是自己的jar包,maven库上没有.最初的解决方案是一个个的deploy ...

  5. Introdution to Spring Mobile

    1. In Eclipse, create a new Maven Project using the spring-mvc-jpa-archetype. 2. Add the spring-mobi ...

  6. UVA 12169 Disgruntled Judge 扩展欧几里得

    /** 题目:UVA 12169 Disgruntled Judge 链接:https://vjudge.net/problem/UVA-12169 题意:原题 思路: a,b范围都在10000以内. ...

  7. openCV中 libopencv-nonfree-dev的安装: undefined reference to `cv::initModule_nonfree()&#39;

    今天照着一起做RGB-D SLAM (3)    , 程序会出现以下的错误: cv::initModule_nonfree(); /home/yhzhao/slam/src/detectFeature ...

  8. jQuery实现限制文本框的输入长度

    jQuery限制文本框输入,包含粘贴. //限制文本框的输入长度 $(function () {  $(document).on("keypress", ".txt-va ...

  9. javascript拼接html代码

    转自开源中国社区:http://www.oschina.net/code/snippet_94055_21640经常做jsp开发的朋友可能遇到一个情况,显示列表数据不是table,而是div或者其他很 ...

  10. 加载Chrome&Firefox配置

    一.加载Chrome配置 分析: Chrome加载配置的方法,只需要改下面一个地方,就是将username改成你本机电脑的名字(不要用中文) '--user-data-dir=C:\Users\use ...