Skip to content

Commit 55ea25b

Browse files
committed
init
0 parents  commit 55ea25b

File tree

7 files changed

+113
-0
lines changed

7 files changed

+113
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
build/
2+
node_modules/

LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2017 Rory Bradford <[email protected]>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is furnished
10+
to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# sd-notify
2+
3+
> Extremely minimal wrapper around [`sd_notify`](https://www.freedesktop.org/software/systemd/man/sd_notify.html)
4+
5+
### Usage
6+
7+
__Example:__
8+
9+
```javascript
10+
const notify = require('sd-notify')
11+
12+
// call notify after some async start up process
13+
// such as in the `http` or `express` listen callback
14+
15+
app.listen(PORT, () => {
16+
console.log('listening on port ' + PORT)
17+
notify()
18+
})
19+
```
20+
21+
Calling `notify()` will inform [__systemd__](https://www.freedesktop.org/software/systemd/man/systemd.service.html) that the process has started, when using `notify` type in a service definition file, eg:
22+
23+
```
24+
[Unit]
25+
Description=Simple notifying service
26+
27+
[Service]
28+
Type=notify
29+
ExecStart=/usr/sbin/simple-notifying-service
30+
31+
[Install]
32+
WantedBy=multi-user.target
33+
```

binding.gyp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"targets": [
3+
{
4+
"target_name": "notify",
5+
"sources": [
6+
"notify.cc"
7+
],
8+
"libraries": [
9+
"-lsystemd"
10+
]
11+
}
12+
]
13+
}

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('bindings')('notify')

notify.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <node.h>
2+
#include <systemd/sd-daemon.h>
3+
4+
#define READY "READY=1"
5+
6+
using namespace v8;
7+
8+
void Notify(const FunctionCallbackInfo<Value>& args) {
9+
sd_notify(0, READY);
10+
}
11+
12+
void Init(Local<Object> exports, Local<Object> module) {
13+
NODE_SET_METHOD(module, "exports", Notify);
14+
}
15+
16+
NODE_MODULE(addon, Init)

package.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"version": "0.0.1",
3+
"scripts": {
4+
"install": "node-gyp rebuild"
5+
},
6+
"gypfile": true,
7+
"name": "sd-notify",
8+
"description": "extremely minimal wrapper around systemd's sd_notify",
9+
"main": "index.js",
10+
"repository": {
11+
"type": "git",
12+
"url": "git+https://github.com/roryrjb/sd-notify.git"
13+
},
14+
"keywords": [
15+
"systemd",
16+
"sd_notify",
17+
"process"
18+
],
19+
"author": "Rory Bradford <[email protected]>",
20+
"license": "MIT",
21+
"bugs": {
22+
"url": "https://github.com/roryrjb/sd-notify/issues"
23+
},
24+
"homepage": "https://github.com/roryrjb/sd-notify#readme",
25+
"dependencies": {
26+
"bindings": "^1.2.1"
27+
}
28+
}

0 commit comments

Comments
 (0)