$ systemctl status node-hello.socketnode-hello.socket Loaded: loaded (/etc/systemd/system/node-hello.socket) Active: active (listening) since Sat, 15 Oct 2011 20:27:47 +0200; 2s ago CGroup: name=systemd:/system/node-hello.socket
$ curl -i http://localhost:1337/HTTP/1.1 200 OKContent-Type: text/plainConnection: keep-aliveTransfer-Encoding: chunkedHello World
Check again, now it will be running:
$ systemctl status node-hello.servicenode-hello.service Loaded: loaded (/etc/systemd/system/node-hello.service) Active: active (running) since Sat, 15 Oct 2011 20:32:10 +0200; 38s ago Main PID: 1159 (node) CGroup: name=systemd:/system/node-hello.service └ 1159 /path/to/bin/node /path/to/hello.js
Only listen to systemd when running under systemd
You can make the systemd usage conditional by checking for the systemd environment variable:
This makes it possible to run the script stand-alone in development, yet use systemd when started through systemd.
Contributing
A jshint file is included to check code style.
Before submitting a pull request, please check your code. For convenience, I've also added a grunt file.
Install the dev dependencies:
$ npm install --dev
Install the grunt cli if you haven't already done so:
$ npm -g install grunt-cli
Run it:
$ grunt
License
(The MIT License)Copyright (C) 2011-2014 by Ruben Vermeersch <ruben@rocketeer.be>Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included inall copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, 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 INTHE SOFTWARE.