Giter VIP home page Giter VIP logo

winser's Introduction

WinSer

Run node.js applications as windows services using nssm.

Installation

$ npm install winser

Command line arguments

-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]

Method 1

I really like this method, in the package.json:

  "scripts": {
    "postinstall": "winser -i -s -c",
    "preuninstall": "winser -r -x -s",
  }

Then, in order to install a node application in lets say a server I will do this:

  npm install git://github.com/myprivate/repository/url.git

The arguments in the postinstall script means:

  • i install
  • s silent, don't display any information
  • c ask for confirmation. This is very helpfull because during development you don't want to install/uninstall the package as a windows service but you will often run "npm install" in the folder, then you can cancel with an 'n'.

The arguments in the preuninstall script means:

  • x stop the service before uninstalling
  • r remove the service
  • s silent, don't display any information

Method 2

Add these two scripts to your package.json:

  "scripts": {
    "install-windows-service": "winser -i",
    "uninstall-windows-service": "winser -r"
  }

Then you can install your service as:

  npm run-script install-windows-service

How it works

When you install your node.js program as a windows service, your program is registered using nssm.exe (which is inside the module folder). Once you start the service nssm.exe is run and nssm.exe will execute "npm start" of your application.

Remember that the default npm action for "start" is "node server.js".

The name of the service will be the same from your package.json "name" setting.

Credits

This project is heavily inspired in

And it uses:

License

(The MIT License)

Copyright (c) 2011 Jose Romaniello <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

winser's People

Contributors

jfromaniello avatar heyhugo avatar jdarling avatar

Watchers

Hugo Ferreira avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.