sd_notify 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/README.md +7 -4
- data/lib/sd_notify.rb +27 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 629460bc4541470e34d3a2990fe5a92d0f6752d2
|
4
|
+
data.tar.gz: e64d96cdd865f4031a990614d527084b98d33dc3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ece83b7a901b00ea7741ee8921af749f4e2c74e67e25b6da1c60d4345eb1e7cd3a1dfcf95d8d9778c272372267a6a7814b8e317d15fc5ffe7a4589a8aaac96ed
|
7
|
+
data.tar.gz: bbe190e841e83be2e5053f879108ee46c71b0707942f99a86cf3e5dd5617d7561b7b271a17f2abf1e220e0fe13034189f246162256fc3bb7b0fadf6271e42686
|
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# ruby-sdnotify
|
2
2
|
|
3
|
-
[](https://badge.fury.io/rb/sd_notify)
|
4
4
|
[](http://www.rubydoc.info/github/agis/ruby-sdnotify)
|
5
5
|
|
6
6
|
A pure Ruby implementation of [sd_notify(3)](https://www.freedesktop.org/software/systemd/man/sd_notify.html) that can be used to
|
@@ -13,16 +13,16 @@ Refer to the [API documentation](http://www.rubydoc.info/github/agis/ruby-sdnoti
|
|
13
13
|
Install ruby-sdnotify:
|
14
14
|
|
15
15
|
```shell
|
16
|
-
$ gem install
|
16
|
+
$ gem install sd_notify
|
17
17
|
```
|
18
18
|
|
19
19
|
If you're using Bundler, add it to your Gemfile:
|
20
20
|
|
21
21
|
```ruby
|
22
|
-
gem "
|
22
|
+
gem "sd_notify"
|
23
23
|
```
|
24
24
|
|
25
|
-
and run `bundle install
|
25
|
+
and run `bundle install`
|
26
26
|
|
27
27
|
## Usage
|
28
28
|
|
@@ -37,6 +37,7 @@ require "sd_notify"
|
|
37
37
|
|
38
38
|
puts "Hello. Booting..."
|
39
39
|
sleep 2 # do some initialization work ...
|
40
|
+
|
40
41
|
SdNotify.ready
|
41
42
|
|
42
43
|
sum = 0
|
@@ -49,6 +50,8 @@ end
|
|
49
50
|
puts "Finished working, shutting down..."
|
50
51
|
SdNotify.stopping
|
51
52
|
sleep 2 # do cleanup work...
|
53
|
+
|
54
|
+
puts "Bye"
|
52
55
|
```
|
53
56
|
|
54
57
|
## License
|
data/lib/sd_notify.rb
CHANGED
@@ -57,6 +57,33 @@ module SdNotify
|
|
57
57
|
notify(FDSTORE, unset_env)
|
58
58
|
end
|
59
59
|
|
60
|
+
# @param [Boolean] true if the service manager expects watchdog keep-alive
|
61
|
+
# notification messages to be sent from this process.
|
62
|
+
#
|
63
|
+
# If the $WATCHDOG_USEC environment variable is set,
|
64
|
+
# and the $WATCHDOG_PID variable is unset or set to the PID of the current
|
65
|
+
# process
|
66
|
+
#
|
67
|
+
# @note Unlike sd_watchdog_enabled(3), this method does not mutate the
|
68
|
+
# environment.
|
69
|
+
def self.watchdog?
|
70
|
+
wd_usec = ENV["WATCHDOG_USEC"]
|
71
|
+
wd_pid = ENV["WATCHDOG_PID"]
|
72
|
+
|
73
|
+
return false if !wd_usec
|
74
|
+
|
75
|
+
begin
|
76
|
+
wd_usec = Integer(wd_usec)
|
77
|
+
rescue
|
78
|
+
return false
|
79
|
+
end
|
80
|
+
|
81
|
+
return false if wd_usec <= 0
|
82
|
+
return true if !wd_pid || wd_pid == $$.to_s
|
83
|
+
|
84
|
+
false
|
85
|
+
end
|
86
|
+
|
60
87
|
# Notify systemd with the provided state, via the notification socket, if
|
61
88
|
# any.
|
62
89
|
#
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sd_notify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Agis Anastasopoulos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: sd_notify can be used to notify systemd about various service status
|
14
14
|
changes of Ruby programs
|
@@ -17,6 +17,7 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
+
- CHANGELOG.md
|
20
21
|
- LICENSE
|
21
22
|
- README.md
|
22
23
|
- lib/sd_notify.rb
|
@@ -40,7 +41,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
40
41
|
version: '0'
|
41
42
|
requirements: []
|
42
43
|
rubyforge_project:
|
43
|
-
rubygems_version: 2.
|
44
|
+
rubygems_version: 2.5.2
|
44
45
|
signing_key:
|
45
46
|
specification_version: 4
|
46
47
|
summary: Pure Ruby implementation of systemd's sd_notify(3)
|