{"_id":"windows-service","_rev":"29-c9493874ea06883017d1fce2b3924241","name":"windows-service","description":"Run Node.JS programs as native Windows Services.","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.0":{"name":"windows-service","version":"1.0.0","description":"Run Node.JS programs as native Windows Services.","main":"index.js","directories":{"example":"example"},"dependencies":{},"contributors":[{"name":"Stephen Vickers","email":"stephen.vickers.sv@gmail.com"}],"repository":{"type":"mercurial","url":"https://bitbucket.org/stephenwvickers/node-windows-service"},"keywords":["service","windows","windows-service"],"author":{"name":"Stephen Vickers","email":"stephen.vickers.sv@gmail.com"},"license":"GPL","scripts":{"install":"node-gyp rebuild"},"gypfile":true,"_id":"windows-service@1.0.0","dist":{"shasum":"6ba6a2507f093f16720a8abb2fa14d9fccb96f21","tarball":"https://registry.npmjs.org/windows-service/-/windows-service-1.0.0.tgz","integrity":"sha512-BdRakLdDlovdCZq6DTzF8SFSHYkzR7iVJfWk3V3J+HYGIz6sBYtItUuXDIzohrmUUnWvkshQOdf8PhZ0522fEg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDUsWVy5UY7WtI/Opm18vHyScWQcNJsWUrVJYFjEpo1VgIgCvd92rv9APLu+3klgLVdtrHgAtfA4VMLu5/zcRiBov4="}]},"_npmVersion":"1.1.69","_npmUser":{"name":"stephen.vickers","email":"stephen.vickers.sv@gmail.com"},"maintainers":[{"name":"stephen.vickers","email":"stephen.vickers.sv@gmail.com"}]},"1.0.1":{"name":"windows-service","version":"1.0.1","description":"Run Node.JS programs as native Windows Services.","main":"index.js","directories":{"example":"example"},"dependencies":{},"contributors":[{"name":"Stephen Vickers","email":"stephen.vickers.sv@gmail.com"}],"repository":{"type":"mercurial","url":"https://bitbucket.org/stephenwvickers/node-windows-service"},"keywords":["service","windows","windows-service"],"author":{"name":"Stephen Vickers","email":"stephen.vickers.sv@gmail.com"},"license":"MIT","scripts":{"install":"node-gyp rebuild"},"gypfile":true,"_id":"windows-service@1.0.1","dist":{"shasum":"60e2585efc917ac5f74db883cb8bafb2058780b1","tarball":"https://registry.npmjs.org/windows-service/-/windows-service-1.0.1.tgz","integrity":"sha512-Gl460MxdbXjzj3J0XsXOOLQCN9KrZpBU640SuRC9eXXup0ebhY1zyskRaPjEDZ47SYNB14tetjR6DcaXZ7UL6w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHqA24cj8DTUTuh+uYxJ2TB1K5xFmF7KLzYDw9EjLTZKAiBzVHLdQYEr/r3h4hk3dvNc0GR0geYQENb1VfaWKKW6Bg=="}]},"_from":".","_npmVersion":"1.2.17","_npmUser":{"name":"stephen.vickers","email":"stephen.vickers.sv@gmail.com"},"maintainers":[{"name":"stephen.vickers","email":"stephen.vickers.sv@gmail.com"}]},"1.0.2":{"name":"windows-service","version":"1.0.2","description":"Run Node.JS programs as native Windows Services.","main":"index.js","directories":{"example":"example"},"dependencies":{},"contributors":[{"name":"Stephen Vickers","email":"stephen.vickers.sv@gmail.com"}],"repository":{"type":"mercurial","url":"https://bitbucket.org/stephenwvickers/node-windows-service"},"keywords":["service","windows","windows-service"],"author":{"name":"Stephen Vickers","email":"stephen.vickers.sv@gmail.com"},"license":"MIT","scripts":{"install":"node-gyp rebuild"},"gypfile":true,"_id":"windows-service@1.0.2","dist":{"shasum":"ef4392507c82f095619051c23ca5a90f49c33981","tarball":"https://registry.npmjs.org/windows-service/-/windows-service-1.0.2.tgz","integrity":"sha512-qz6NYC5OUbaZMWDLR90Cj5hFQjUumeqU0TqYxr3vmD1xKlZDpQg4FmBA/QQf0zxC07uV3QQk5b2xYjEdJSguSA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCl2uQkuLfk705jgu4my5iUNi5ONp+J1nm+shZq9sXFBgIhAP3cY2/gNpfvw0+Jm84vV3qzYhtkzJ3f8f8w7T5HyF+N"}]},"_from":".","_npmVersion":"1.2.17","_npmUser":{"name":"stephen.vickers","email":"stephen.vickers.sv@gmail.com"},"maintainers":[{"name":"stephen.vickers","email":"stephen.vickers.sv@gmail.com"}]},"1.0.3":{"name":"windows-service","version":"1.0.3","description":"Run Node.JS programs as native Windows Services.","main":"index.js","directories":{"example":"example"},"dependencies":{},"contributors":[{"name":"Stephen Vickers","email":"stephen.vickers.sv@gmail.com"}],"repository":{"type":"mercurial","url":"https://bitbucket.org/stephenwvickers/node-windows-service"},"keywords":["service","windows","windows-service"],"author":{"name":"Stephen Vickers","email":"stephen.vickers.sv@gmail.com"},"license":"MIT","scripts":{"install":"node-gyp rebuild"},"gypfile":true,"_id":"windows-service@1.0.3","_shasum":"74d4548b46b4b658c9f48654fe77ad42a442763b","_from":".","_npmVersion":"1.4.14","_npmUser":{"name":"stephen.vickers","email":"stephen.vickers.sv@gmail.com"},"maintainers":[{"name":"stephen.vickers","email":"stephen.vickers.sv@gmail.com"}],"dist":{"shasum":"74d4548b46b4b658c9f48654fe77ad42a442763b","tarball":"https://registry.npmjs.org/windows-service/-/windows-service-1.0.3.tgz","integrity":"sha512-OOEZMGBnptnrnNw5nM6+ovHiAwBWn2KCrlk1YojB06x6UFmM+Z7HCT/Y+99ibvfJTHvTtWeliRe8uCw3GZ8+pg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCfG6Hp8KLPcRT/gn309mRwvmDxqqGRTZbfOEfR37pD4gIhALSv/G/m+bYGoI4qFCrqu9caGqxCn9AuLePeIKxzZ3Iz"}]}},"1.0.4":{"name":"windows-service","version":"1.0.4","description":"Run Node.JS programs as native Windows Services.","main":"index.js","directories":{"example":"example"},"dependencies":{},"contributors":[{"name":"Stephen Vickers","email":"stephen.vickers.sv@gmail.com"}],"repository":{"type":"mercurial","url":"https://bitbucket.org/stephenwvickers/node-windows-service"},"keywords":["service","windows","windows-service"],"author":{"name":"Stephen Vickers","email":"stephen.vickers.sv@gmail.com"},"license":"MIT","scripts":{"install":"node-gyp rebuild"},"gypfile":true,"_id":"windows-service@1.0.4","_shasum":"9a1dc8328f597e89eea31fc2be50df8df9c93477","_from":".","_npmVersion":"1.4.14","_npmUser":{"name":"stephen.vickers","email":"stephen.vickers.sv@gmail.com"},"maintainers":[{"name":"stephen.vickers","email":"stephen.vickers.sv@gmail.com"}],"dist":{"shasum":"9a1dc8328f597e89eea31fc2be50df8df9c93477","tarball":"https://registry.npmjs.org/windows-service/-/windows-service-1.0.4.tgz","integrity":"sha512-Q6O9AVM6JW2i6G8qyLL+1bUniLfdIwLTQAIfkf1jc3ndCxzN5HSeXXJCQT+UnS92iwkn+kmM4RJSZ9/DJt8qqQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGNfqFS0vlc5ovJjP9l1VzKW6hz8BuknC227LX8Q7dbUAiEA622D5LOUMwn+S33LXJpKvSyW4hr4JA+nOoH15zkEi+Q="}]}},"1.1.0":{"name":"windows-service","version":"1.1.0","description":"Run Node.JS programs as native Windows Services.","main":"index.js","directories":{"example":"example"},"dependencies":{},"contributors":[{"name":"Stephen Vickers","email":"stephen.vickers.sv@gmail.com"}],"repository":{"type":"git","url":"git://github.com/stephenwvickers/node-windows-service.git"},"keywords":["service","windows","windows-service"],"author":{"name":"Stephen Vickers","email":"stephen.vickers.sv@gmail.com"},"license":"MIT","scripts":{"install":"node-gyp rebuild"},"gypfile":true,"gitHead":"26ff5edf0b95246c14974e25be0f0e6a9385f892","bugs":{"url":"https://github.com/stephenwvickers/node-windows-service/issues"},"homepage":"https://github.com/stephenwvickers/node-windows-service#readme","_id":"windows-service@1.1.0","_shasum":"095ee99b79ad90dc541826579da4f073971ecb2c","_from":".","_npmVersion":"2.14.2","_nodeVersion":"4.0.0","_npmUser":{"name":"stephen.vickers","email":"stephen.vickers.sv@gmail.com"},"dist":{"shasum":"095ee99b79ad90dc541826579da4f073971ecb2c","tarball":"https://registry.npmjs.org/windows-service/-/windows-service-1.1.0.tgz","integrity":"sha512-CAqnOjEzWwU7LW/oSWJpV0TsGd3K0Fm/D3RNBz8bY9W48g89FCUV5R0iXAzmzpl+mKWy6eKjHz5TomRYi2XVgA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDPXEE2o12avh925AfNchAYv1nu7Ae8JVNcc3VkIbIfxwIgP4QSWmes44fFyVANg/cMwqeqnZZKnQR+gMLa47Pn7y8="}]},"maintainers":[{"name":"stephen.vickers","email":"stephen.vickers.sv@gmail.com"}]}},"readme":"\n# windows-service\n\n**NOTE** This module has been deprecated in favour of the\n[os-service][os-service] module, please use that module instead.  The two\nmodules differ in that the `add()` and `remove()` functions require a callback.\n\n[os-service]: https://www.npmjs.com/package/os-service\n\nThis module implements the ability to run a [Node.js][nodejs] based JavaScript\nprogram as a native Windows service.\n\nThis module is installed using [node package manager (npm)][npm]:\n\n    # This module contains C++ source code which will be compiled\n    # during installation using node-gyp.  A suitable build chain\n    # must be configured before installation.\n    \n    npm install windows-service\n\nIt is loaded using the `require()` function:\n\n    var service = require (\"windows-service\");\n\nA program can then be added, removed and run as a Windows service:\n\n    service.add (\"My Service\");\n    \n    service.remove (\"My Service\");\n    \n    var logStream = fs.createWriteStream (\"my-service.log\");\n    \n    service.run (logStream, function () {\n        console.log (\"stop request received\");\n        service.stop ();\n    });\n\n[nodejs]: http://nodejs.org \"Node.js\"\n[npm]: https://npmjs.org/ \"npm\"\n\n# Batch Service Creation\n\nTwo approaches can be taken when adding and removing services.\n\nIn the first approach a program can be responsible for adding, removing and\nstarting itself as a service.  This is typically achieved by supporting\nprogram arguments such as `--add`, `--remove`, and `--run`, and executing the\nappropriate action.\n\nThe following example adds the calling program as a service when called\nwith a `--add` parameter, and removes the created service when called with a\n`--remove` parameter:\n\n    if (process.argv[2] == \"--add\") {\n        service.add (\"My Service\", {programArgs: [\"--run\"]});\n    } else if (process.argv[2] == \"--remove\") {\n        service.remove (\"My Service\");\n    } else if (process.argv[2] == \"--run\") {\n        var logStream = fs.createWriteStream (process.argv[1] + \".log\");\n        \n        service.run (logStream, function () {\n            service.stop (0);\n        });\n        \n        // Run service program code...\n    } else {\n        // Show usage...\n    }\n\nNote the `--run` argument passed in the `options` parameter to the\n`service.add()` function.  When the service is started using the Windows\nService Control Manager the first argument to the program will be `--run`.\nThe above program checks for this and if specified runs as a service using\nthe `service.run()` function.\n\nAlso note that neither the node binary or the programs fully qualified path\nare specified.  These parameters are automatically calculated it not\nspecified.  Refer to the `service.add()` function description for details\nabout how this works.\n\nIn the second approach a dedicated service management program can be\nresponsible for adding and removing many services in batch.  The program\nadding and removing services is not a service itself, and would never call\nthe `service.run()` function.\n\nThe following example adds or removes number of services:\n\n    if (program.argv[2] == \"--add\") {\n        service.add (\"Service 1\", {programPath: \"c:\\example\\service1.js\"});\n        service.add (\"Service 2\", {programPath: \"c:\\example\\service2.js\"});\n        service.add (\"Service 3\", {programPath: \"c:\\example\\service3.js\"});\n    } else {\n        service.remove (\"Service 1\");\n        service.remove (\"Service 2\");\n        service.remove (\"Service 3\");\n    }\n\nNote that unlike the previous example the `--run` argument is not passed in\nthe `options` parameter to the `service.add()` function.  Since each service\nprogram does not add or remove itself as a service it only needs to run, and\nas such does not need to be told to so.\n\nAlso note that the `programPath` argument is passed in the options parameter\nto the `service.add()` function, to specify the fully qualified path to each\nservice program - which would otherwise default to the service management\nprogram adding the services.\n\nEach of the service programs can simply start themselves as services using the\nfollowing code:\n\n    var logStream = fs.createWriteStream (process.argv[1] + \".log\");\n    \n    service.run (logStream, function () {\n        service.stop (0);\n    });\n    \n    // Run service program code...\n\n# Running Service Programs\n\nWhen a service program starts it can always call the `service.run()` function\nregardless of whether it is started at the console, or by the Windows Service\nControl Manager.\n\nWhen the `service.run()` function is called this module will attempt to\nconnect to the Windows Service Control Manager so that control requests can be\nreceived - so that the service can be stopped.\n\nWhen starting a program at the console an attempt to connect to the Windows\nService Control Manager will fail.  In this case the `service.run()` function\nwill assume the program is running at the console and silently ignore this\nerror.\n\nThis behaviour results in a program which can be run either at the console or\nthe Windows Service Control Manager with no change.\n\n# Current Working Directory\n\nUpon starting the current working directory of a service program will be the\n`\"%windir%\\system32\"` directory (i.e. `c:\\windows\\system32`).  Service\nprograms need to consider this when working with relative directory and file\npaths.\n\nThis path will most likely be different when running the same program at the\nconsole, so a service program may wish to change the current working\ndirectory to a more suitable location using the `process.chdir()` function to\navoid different behaviour between the two methods of starting a program.\n\n# Using This Module\n\nGiven the intended purpose of this module only Windows platforms are\nsupported.\n\nHowever, this module aims to support other platforms in the future.  That is\nit aims to support installing as a service on other platforms - by creating\n`/etc/init.d/...` scripts for example - so that the same service management\ncode can be used to abstract away platform differences.\n\n## service.add (name, [options])\n\nThe `add()` function adds a Windows service.\n\nThe `name` parameter specifies the name of the created service.  The optional\n`options` parameter is an object, and can contain the following items:\n\n * `displayName` - The services display name, defaults to the `name` parameter\n * `nodePath` - The fully qualified path to the node binary used to run the\n   service (i.e. `c:\\Program Files\\nodejs\\node.exe`, defaults to the value of\n   `process.execPath`\n * `nodeArgs` - An array of strings specifying parameters to pass to\n   `nodePath`, defaults to `[]`\n * `programPath` - The program to run using `nodePath`, defaults to the value\n   of `process.argv[1]`\n * `programArgs` - An array of strings specifying parameters to pass to\n   `programPath`, defaults to `[]`\n\nThe service will be set to automatically start at boot time, but not started.\nThe service can be started using the `net start \"My Service\"` command.\n\nAn exception will be thrown if the service could not be added.  The error will\nbe an instance of the `Error` class.\n\nThe following example installs a service named `My Service`, it explicitly\nspecifies the services display name, and specifies a number of parameters to\nthe program:\n\n    var options = {\n        displayName: \"My Service\",\n        programArgs: [\"--server-port\", 8888]\n    };\n    \n    service.add (\"my-service\", options);\n\n## service.remove (name)\n\nThe `remove()` function removes a Windows service.\n\nThe `name` parameter specifies the name of the service to remove.  This will\nbe the same `name` parameter specified when adding the service.\n\nThe service must be in a stopped state for it to be removed.  The\n`net stop \"My Service\"` command can be used to stop the service before it is\nto be removed.\n\nAn exception will be thrown if the service could not be removed.  The error\nwill be an instance of the `Error` class.\n\nThe following example removes the service named `My Service`:\n\n    service.remove (\"My Service\");\n\n## service.run (stdoutLogStream, [stderrLogStream,] callback)\n\nThe `run()` function will connect the calling program to the Windows Service\nControl Manager, allowing the program to run as a Windows service.\n\nThe programs `process.stdout` stream will be replaced with the\n`stdoutLogStream` parameter, and the programs `process.stderr` stream\nreplaced with the `stdoutLogStream` parameter (this allows the redirection of\nall `console.log()` type calls to a service specific log file).  If the\n`stderrLogStream` parameter is not specified the programs `process.stderr`\nstream will be replaced with the `stdoutLogStream` parameter.  The `callback`\nfunction will be called when the service receives a stop request, e.g. because\nthe Windows Service Controller was used to send a stop request to the service.\n\nThe program should perform cleanup tasks and then call the `service.stop()`\nfunction.\n\nThe following example connects the calling program to the Windows Service\nControl Manager, it uses the same log stream for standard output and standard\nerror:\n\n    var logStream = fs.createWriteStream (\"my-service.log\");\n    \n    service.run (logStream, function () {\n        console.log (\"stop request received\");\n        service.stop ();\n    });\n\n## service.stop ([rcode])\n\nThe `stop()` function will cause the service to stop, and the calling program\nto exit.\n\nOnce the service has been stopped this function will terminate the program by\ncalling the `process.exit()` function, passing to it the `rcode` parameter\nwhich defaults to `0`.  Before calling this function ensure the program has\nfinished performing cleanup tasks.\n\n**BE AWARE, THIS FUNCTION WILL NOT RETURN.**\n\nThe following example stops the calling program specifying a return code of\n`0`, the function will not return:\n\n    var logStream = fs.createWriteStream (\"my-service.log\");\n\n    service.run (logStream, function () {\n        console.log (\"stop request received\");\n        service.stop (0);\n    });\n\n# Example Programs\n\nExample programs are included under the modules `example` directory.\n\n# Bugs & Known Issues\n\nNone, yet!\n\nBug reports should be sent to <stephen.vickers.sv@gmail.com>.\n\n# Changes\n\n## Version 1.0.0 - 21/02/2013\n\n * Initial release\n\n## Version 1.0.1 - 11/05/2013\n\n * `runInitialised` was not set to `true` when the service is `run()` for the\n   first time in index.js\n * Use MIT license instead of GPL\n\n## Version 1.0.2 - 15/08/2013\n\n * The variable `rcode` in the `run()` function defined in `service.cc` was\n   not used\n\n## Version 1.0.3 - 23/08/2014\n\n * Windows reports an error when stopping the service, indicate to Windows\n   the service is stopping to prevent Windows from generating an error\n\n## Version 1.0.4 - 26/08/2014\n\n * High CPU utilisation when running services as console programs\n\n## Version 1.1.0 - 20/09/2015\n\n * Host repository on GitHub\n\n# Roadmap\n\nIn no particular order:\n\n * Specify whether the service should auto-starting on boot\n * Add provisions for running under UNIX platforms (i.e. daemonize,\n   conditional compile of C++ code for Windows only, create `/etc/init.d/...`\n   scripts)\n\nSuggestions and requirements should be sent to <stephen.vickers.sv@gmail.com>.\n\n# License\n\nCopyright (c) 2013 Stephen Vickers\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n\n# Author\n\nStephen Vickers <stephen.vickers.sv@gmail.com>\n","maintainers":[{"name":"stephen.vickers","email":"stephen.vickers.sv@gmail.com"}],"time":{"modified":"2022-06-29T02:09:27.733Z","created":"2013-02-21T22:24:14.290Z","1.0.0":"2013-02-21T22:24:17.900Z","1.0.1":"2013-05-11T14:57:39.480Z","1.0.2":"2013-08-15T21:35:25.871Z","1.0.3":"2014-08-23T21:09:21.697Z","1.0.4":"2014-08-26T20:35:42.680Z","1.1.0":"2015-09-20T19:00:13.951Z"},"author":{"name":"Stephen Vickers","email":"stephen.vickers.sv@gmail.com"},"repository":{"type":"git","url":"git://github.com/stephenwvickers/node-windows-service.git"},"keywords":["service","windows","windows-service"],"contributors":[{"name":"Stephen Vickers","email":"stephen.vickers.sv@gmail.com"}],"license":"MIT","readmeFilename":"README.md","users":{"lazycoder":true,"andris":true,"digitalextremist":true,"xieranmaya":true,"unforgiven512":true,"rebolon":true,"bobby.luisi":true},"homepage":"https://github.com/stephenwvickers/node-windows-service#readme","bugs":{"url":"https://github.com/stephenwvickers/node-windows-service/issues"}}