pid_lock 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pid_lock.rb +9 -0
- data/lib/pid_lock/version.rb +1 -1
- data/pid_lock.gemspec +1 -0
- data/test/test_pid_lock.rb +7 -0
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc28faa9e1aef44eb8a7abbce40928ce258f8bca
|
4
|
+
data.tar.gz: 39b5a5c7e50ebae667f6f794d689b166ba0ee402
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56a9cf07f838575d5f1e701f7a01ff6e44eb2492198b8a244fe4f315c7385c2adff6e563e3812a474d33847676204ce0defebeaed3a7187ecc27ff2825a4ca5a
|
7
|
+
data.tar.gz: 1fa4734eec304ff54f7ce77c374b500d96bc51cd8bc346eeb70a7850b339d6acdb1acdc5d2a218e1442fd57f0270dcea8447dfc3621fc1c619f044df68b97b97
|
data/lib/pid_lock.rb
CHANGED
@@ -29,6 +29,15 @@ module PidLock
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
+
def stop(pid_name)
|
33
|
+
return unless File.exists?(File.join(pid_path, "#{pid_name}.pid"))
|
34
|
+
pid = File.read(File.join(pid_path, "#{pid_name}.pid"))
|
35
|
+
unless pid.to_s.empty?
|
36
|
+
Process.kill("QUIT", pid.to_i) rescue nil
|
37
|
+
end
|
38
|
+
unlock(pid_name)
|
39
|
+
end
|
40
|
+
|
32
41
|
def pid(pid_name)
|
33
42
|
File.read(File.join(pid_path, "#{pid_name}.pid")).to_i
|
34
43
|
end
|
data/lib/pid_lock/version.rb
CHANGED
data/pid_lock.gemspec
CHANGED
data/test/test_pid_lock.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'test/unit'
|
2
|
+
require "pry"
|
2
3
|
|
3
4
|
class TestPidLock < Test::Unit::TestCase
|
4
5
|
def test_lock
|
@@ -15,4 +16,10 @@ class TestPidLock < Test::Unit::TestCase
|
|
15
16
|
assert_equal false, PidLock.locked?('test')
|
16
17
|
assert_equal false, File.exist?(File.join(PidLock.pid_path, "test.pid"))
|
17
18
|
end
|
19
|
+
|
20
|
+
def test_stop
|
21
|
+
PidLock.lock('test')
|
22
|
+
PidLock.stop("test")
|
23
|
+
assert_equal false, PidLock.locked?('test')
|
24
|
+
end
|
18
25
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pid_lock
|
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
|
- xuxiangyang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.4'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: test-unit
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.5'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.5'
|
41
55
|
description: ruby pid lock file
|
42
56
|
email:
|
43
57
|
- 54049924@qq.com
|
@@ -74,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
88
|
version: '0'
|
75
89
|
requirements: []
|
76
90
|
rubyforge_project:
|
77
|
-
rubygems_version: 2.
|
91
|
+
rubygems_version: 2.4.8
|
78
92
|
signing_key:
|
79
93
|
specification_version: 4
|
80
94
|
summary: ruby pid lock file
|