daemon_signals 0.0.1
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 +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +34 -0
- data/Rakefile +9 -0
- data/daemon_signals.gemspec +24 -0
- data/lib/daemon_signals.rb +14 -0
- data/lib/daemon_signals/version.rb +3 -0
- data/test/test_signals.rb +14 -0
- metadata +86 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 49f55dc93513815f1cee1f8cedab5ad341c9b9ad
|
4
|
+
data.tar.gz: cb33ef259fdfa595e0b6dd277af11a2331428ae7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 62f0e49f1f79df0f429b6268ce5c962b17e2c3a4cc8c27f4b14087e970b276ad40d7c58b7b4c98c6a728107d84b13c8a1bb7a3c9b91f164d0cd3ee655f4bb167
|
7
|
+
data.tar.gz: 2160d382b82a7379ab400b307b856655c37dd0196a30c4e060b9ec8ef86fae39a62965866dfeed1cbff770d73a98994dcf1cb3705079737cee17d4eb35d4cda4
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Sal Scotto
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# DaemonSignals
|
2
|
+
|
3
|
+
This gem enhances Process.daemon to raise a signal (SIGCONT) when your process has bene daemonized. This gem is has been created
|
4
|
+
to handle daemonization in web servers like puma, so that any background threads you may have created can be restarted if they were
|
5
|
+
started BEFORE the daemon call was issued. IF you using gems like puma be sure to include this gem after puma as it redefines Process.daemon
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'daemon_signals'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install daemon_signals
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
1. require 'daemon_signals'
|
24
|
+
2. Signal.trap('CONT') do
|
25
|
+
... code on process daemonization
|
26
|
+
end
|
27
|
+
3. Profit
|
28
|
+
## Contributing
|
29
|
+
|
30
|
+
1. Fork it ( http://github.com/<my-github-username>/daemon_signals/fork )
|
31
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
32
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
33
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
34
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'daemon_signals/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "daemon_signals"
|
8
|
+
spec.version = DaemonSignals::VERSION
|
9
|
+
spec.authors = ["Sal Scotto"]
|
10
|
+
spec.email = ["sal.scotto@gmail.com"]
|
11
|
+
spec.summary = %q{Extends Process.daemon to raise a Signal when executed}
|
12
|
+
spec.description = %q{There are times when you need to restart threads and jobs if your process is daemonized. This gem provides it.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rubysl-test-unit"
|
24
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "daemon_signals/version"
|
2
|
+
|
3
|
+
module DaemonSignals
|
4
|
+
# Enhance the Process module
|
5
|
+
end
|
6
|
+
module Process
|
7
|
+
class << self
|
8
|
+
alias :orignial_daemon :daemon
|
9
|
+
def daemon(a=false,b=false)
|
10
|
+
orignial_daemon(a,b)
|
11
|
+
Process.kill('CONT',0)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'daemon_signals'
|
3
|
+
|
4
|
+
class DaemonSignalsTest < Test::Unit::TestCase
|
5
|
+
def test_signal_raised
|
6
|
+
signaled = false
|
7
|
+
Signal.trap('CONT') do
|
8
|
+
signaled = true
|
9
|
+
end
|
10
|
+
Process.daemon
|
11
|
+
sleep 0.1 until signaled
|
12
|
+
assert(signaled)
|
13
|
+
end
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: daemon_signals
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sal Scotto
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2014-01-15 00:00:00 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
prerelease: false
|
17
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: "1.5"
|
22
|
+
type: :development
|
23
|
+
version_requirements: *id001
|
24
|
+
- !ruby/object:Gem::Dependency
|
25
|
+
name: rake
|
26
|
+
prerelease: false
|
27
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- &id003
|
30
|
+
- ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: "0"
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id002
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rubysl-test-unit
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- *id003
|
41
|
+
type: :development
|
42
|
+
version_requirements: *id004
|
43
|
+
description: There are times when you need to restart threads and jobs if your process is daemonized. This gem provides it.
|
44
|
+
email:
|
45
|
+
- sal.scotto@gmail.com
|
46
|
+
executables: []
|
47
|
+
|
48
|
+
extensions: []
|
49
|
+
|
50
|
+
extra_rdoc_files: []
|
51
|
+
|
52
|
+
files:
|
53
|
+
- .gitignore
|
54
|
+
- Gemfile
|
55
|
+
- LICENSE.txt
|
56
|
+
- README.md
|
57
|
+
- Rakefile
|
58
|
+
- daemon_signals.gemspec
|
59
|
+
- lib/daemon_signals.rb
|
60
|
+
- lib/daemon_signals/version.rb
|
61
|
+
- test/test_signals.rb
|
62
|
+
homepage: ""
|
63
|
+
licenses:
|
64
|
+
- MIT
|
65
|
+
metadata: {}
|
66
|
+
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- *id003
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- *id003
|
78
|
+
requirements: []
|
79
|
+
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 2.2.1
|
82
|
+
signing_key:
|
83
|
+
specification_version: 4
|
84
|
+
summary: Extends Process.daemon to raise a Signal when executed
|
85
|
+
test_files:
|
86
|
+
- test/test_signals.rb
|