sd_notify 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +3 -0
  3. data/LICENSE +1 -1
  4. data/README.md +22 -9
  5. data/lib/sd_notify.rb +6 -8
  6. metadata +46 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 629460bc4541470e34d3a2990fe5a92d0f6752d2
4
- data.tar.gz: e64d96cdd865f4031a990614d527084b98d33dc3
2
+ SHA256:
3
+ metadata.gz: c89da4e885a9b87c80d22e0ae73d626c0605c4d2ae2daadfeedac5023524f8db
4
+ data.tar.gz: 3f248414d244113af69b82d00e65e98609f25d0097610b1aef79708b32c590d3
5
5
  SHA512:
6
- metadata.gz: ece83b7a901b00ea7741ee8921af749f4e2c74e67e25b6da1c60d4345eb1e7cd3a1dfcf95d8d9778c272372267a6a7814b8e317d15fc5ffe7a4589a8aaac96ed
7
- data.tar.gz: bbe190e841e83be2e5053f879108ee46c71b0707942f99a86cf3e5dd5617d7561b7b271a17f2abf1e220e0fe13034189f246162256fc3bb7b0fadf6271e42686
6
+ metadata.gz: 39ce82f7bb05750e988805ce5bdaa8a1f00318198115a217f47a7e982a9fbb40afbd8c613321cbd475352fb28aecb8b019704eed365d44bc56a2223d0c8d2490
7
+ data.tar.gz: ab4a9a04520a17bdac64ed12c671313c0be20738f7b79c6ea0f2a9864ddf4fffe7aab68de269cc1875d86782d31365c3017a7b6400be2b74dc254124451138a7
data/CHANGELOG.md CHANGED
@@ -4,7 +4,10 @@ Breaking changes are prefixed with a "[BREAKING]" label.
4
4
 
5
5
  ## master (unreleased)
6
6
 
7
+ ## 0.1.1 (2021-02-27)
7
8
 
9
+ This is a release with no actual changes in the source code. It's merely added
10
+ to tackle #4.
8
11
 
9
12
 
10
13
 
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright (c) 2017 Agis Anastasopoulos
3
+ Copyright (c) 2017, 2018, 2019, 2020 Agis Anastasopoulos
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  this software and associated documentation files (the "Software"), to deal in
data/README.md CHANGED
@@ -1,9 +1,12 @@
1
1
  # ruby-sdnotify
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/sd_notify.svg)](https://badge.fury.io/rb/sd_notify)
4
+ [![Build Status](https://travis-ci.org/agis/ruby-sdnotify.svg?branch=master)](https://travis-ci.org/agis/ruby-sdnotify)
4
5
  [![Documentation](http://img.shields.io/badge/yard-docs-blue.svg)](http://www.rubydoc.info/github/agis/ruby-sdnotify)
6
+ [![License](https://img.shields.io/github/license/mashape/apistatus.svg)](LICENSE)
5
7
 
6
- A pure Ruby implementation of [sd_notify(3)](https://www.freedesktop.org/software/systemd/man/sd_notify.html) that can be used to
8
+
9
+ A pure-Ruby implementation of [sd_notify(3)](https://www.freedesktop.org/software/systemd/man/sd_notify.html) that can be used to
7
10
  communicate state changes of Ruby programs to [systemd](https://www.freedesktop.org/wiki/Software/systemd/).
8
11
 
9
12
  Refer to the [API documentation](http://www.rubydoc.info/github/agis/ruby-sdnotify) for more info.
@@ -22,34 +25,44 @@ If you're using Bundler, add it to your Gemfile:
22
25
  gem "sd_notify"
23
26
  ```
24
27
 
25
- and run `bundle install`
26
-
27
28
  ## Usage
28
29
 
29
30
  The [API](http://www.rubydoc.info/github/agis/ruby-sdnotify) is mostly tied to
30
31
  the official implementation, therefore refer to the [sd_notify(3) man pages](https://www.freedesktop.org/software/systemd/man/sd_notify.html)
31
32
  for detailed description of how the notification mechanism works.
32
33
 
33
- An example (assuming the program shipped as a systemd service):
34
+ An example involving a dummy workload (assuming the program is shipped as a
35
+ systemd service):
34
36
 
35
37
  ```ruby
36
38
  require "sd_notify"
37
39
 
38
- puts "Hello. Booting..."
39
- sleep 2 # do some initialization work ...
40
+ puts "Hello! Booting..."
40
41
 
42
+ # doing some initialization work...
43
+ sleep 2
44
+
45
+ # notify systemd that we're ready
41
46
  SdNotify.ready
42
47
 
43
48
  sum = 0
44
49
  5.times do |i|
45
- sleep 1 # perform some work
50
+ # doing our main work...
51
+ sleep 1
52
+
46
53
  sum += 1
54
+
55
+ # notify systemd of our progress
47
56
  SdNotify.status("{sum} jobs completed")
48
57
  end
49
58
 
50
- puts "Finished working, shutting down..."
59
+ puts "Finished working. Shutting down..."
60
+
61
+ # notify systemd we're shutting down
51
62
  SdNotify.stopping
52
- sleep 2 # do cleanup work...
63
+
64
+ # doing some cleanup work...
65
+ sleep 2
53
66
 
54
67
  puts "Bye"
55
68
  ```
data/lib/sd_notify.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "socket"
2
4
 
3
5
  # SdNotify is a pure-Ruby implementation of sd_notify(3). It can be used to
@@ -108,17 +110,13 @@ module SdNotify
108
110
 
109
111
  ENV.delete("NOTIFY_SOCKET") if unset_env
110
112
 
111
- connected = false
112
-
113
113
  begin
114
- sock = Addrinfo.unix(sock, :DGRAM).connect
115
- connected = true
116
- sock.close_on_exec = true
117
- sock.write(state)
114
+ Addrinfo.unix(sock, :DGRAM).connect do |s|
115
+ s.close_on_exec = true
116
+ s.write(state)
117
+ end
118
118
  rescue StandardError => e
119
119
  raise NotifyError, "#{e.class}: #{e.message}", e.backtrace
120
- ensure
121
- sock.close if connected
122
120
  end
123
121
  end
124
122
  end
metadata CHANGED
@@ -1,15 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sd_notify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Agis Anastasopoulos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-18 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2021-02-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: minitest
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubocop
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop-performance
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
13
55
  description: sd_notify can be used to notify systemd about various service status
14
56
  changes of Ruby programs
15
57
  email: agis.anast@gmail.com
@@ -41,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
41
83
  version: '0'
42
84
  requirements: []
43
85
  rubyforge_project:
44
- rubygems_version: 2.5.2
86
+ rubygems_version: 2.7.6.2
45
87
  signing_key:
46
88
  specification_version: 4
47
89
  summary: Pure Ruby implementation of systemd's sd_notify(3)