sd_notify 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -0
  3. data/README.md +7 -4
  4. data/lib/sd_notify.rb +27 -0
  5. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2ca0c254a94d204fddc97bf051fbf5e1a3ad8697
4
- data.tar.gz: 342501c3de33d0cd45edabbf8f4a9b5adc2ba41f
3
+ metadata.gz: 629460bc4541470e34d3a2990fe5a92d0f6752d2
4
+ data.tar.gz: e64d96cdd865f4031a990614d527084b98d33dc3
5
5
  SHA512:
6
- metadata.gz: be54ed4907b91bbd92963cb0cd4b524ec2b2763346f92772f99a5bd2d723faa05a34dea3ed23319c85fb4fd159d60a74dcdad4e5d2c8ecdb34a99136f6d3d4be
7
- data.tar.gz: 736bd5cbdd81d7a18fe4aabe9c57762545a3c16b428f06bdbba086858249b399ab72c7ee134745a4fe4f5a33e276a940c40bc9d50368682deaffa8054fc3d177
6
+ metadata.gz: ece83b7a901b00ea7741ee8921af749f4e2c74e67e25b6da1c60d4345eb1e7cd3a1dfcf95d8d9778c272372267a6a7814b8e317d15fc5ffe7a4589a8aaac96ed
7
+ data.tar.gz: bbe190e841e83be2e5053f879108ee46c71b0707942f99a86cf3e5dd5617d7561b7b271a17f2abf1e220e0fe13034189f246162256fc3bb7b0fadf6271e42686
@@ -0,0 +1,15 @@
1
+ # Changelog
2
+
3
+ Breaking changes are prefixed with a "[BREAKING]" label.
4
+
5
+ ## master (unreleased)
6
+
7
+
8
+
9
+
10
+
11
+ ## 0.1.0 (2018-05-15)
12
+
13
+ ### Added
14
+
15
+ - `SdNotify.watchdog?` [[#1](https://github.com/agis/ruby-sdnotify/issues/1)]
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # ruby-sdnotify
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/ruby-sdnotify.svg)](https://badge.fury.io/rb/ruby-sdnotify)
3
+ [![Gem Version](https://badge.fury.io/rb/sd_notify.svg)](https://badge.fury.io/rb/sd_notify)
4
4
  [![Documentation](http://img.shields.io/badge/yard-docs-blue.svg)](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 ruby-sdnotify
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 "ruby-sdnotify"
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
@@ -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.1
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: 2017-09-15 00:00:00.000000000 Z
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.6.13
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)