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. std::vector

    Vector Vectors are sequence containers representing arrays that can change in size. Just like arrays ...

  2. Java获取系统默认浏览器打开链接

    package com.ylx.test; public class DesktopBrowers { public static void main(String[] args) { // 判断当前 ...

  3. SpringMVC学习(一)小demo

    首先看一下整个demo的项目结构: 第一步是导入Spring MVC单独使用时的最少jar包: 第二步在项目的web.xml中配置Spring MVC提供的拦截请求的Servlet: 全类名是:org ...

  4. centos6.5下Nginx的安装

    此处主要介绍通过配置Nginx的官方yum源,通过yum安装Nginx.参考官网:http://nginx.org/en/linux_packages.html 主要分为以下步骤: 1.配置yum源: ...

  5. FineReport实现java报表多级上报的效果图

    Java报表-上报流程管理 Java报表-上报任务管理 Java报表-我的上报任务 Java报表-系统说明

  6. python 开发技巧(3)-- 连接mysql 出现错误 ModuleNotFoundError: No module named 'MySQLdb'

    python3中使用mysql报错ModuleNotFoundError: No module named 'MySQLdb' 原因是:在python2.x中用mysqldb,但是在python3.x ...

  7. CSS学习(二)- 有关 hasLayout 和 BFC

    1. hasLayout 概念说明 ‘Layout’ 可以被某些 CSS property(特性)不可逆的触发,而某些 HTML 元素本身就具有 layout . ‘Layout’ 在 IE 中可以通 ...

  8. 表变量、临时表(with as ,create table)

    1.declare @t table(CountryRegionCode nvarchar(3))insert into @t(CountryRegionCode)  (select CountryR ...

  9. PowerDesigner如何导出表到word的方法

    from:https://jingyan.baidu.com/article/295430f1c385970c7f005056.html PowerDesigner如何导出表到word的方法 听语音 ...

  10. linux用户与组管理

    普通用户的管理 用户管理的基本任务包括添加新用户.删除用户.修改用户属性以及对现有用户的访问参数进行设置.与密切 相关的文件包含/etc/passwd./etc/shadow以及/home目录下的文件 ...